c# - 如何在 Xamarin.Forms 中进行通知
问题描述
如何使用 XAML 或 C# 代码在 Xamarin.Forms 中发出通知?
我可以在带有 Xamarin.Forms 的 Ios 中使用它吗?
解决方案
看看精彩的Toasts.Forms.Plugin
您可以简单地触发这样的通知
var notificator = DependencyService.Get<IToastNotificator>();
var options = new NotificationOptions()
{
Title = "Title",
Description = "Description"
};
await notificator.Notify(options);
如果用户单击、关闭等通知,您可以事件做出反应
var result = await notificator.Notify(options);
// result is a NotificationResult with a NotificationAction in it
public enum NotificationAction
{
Timeout = 1, // Hides by itself
Clicked = 2, // User clicked on notification
Dismissed = 4, // User manually dismissed notification
ApplicationHidden = 8, // Application went to background
Failed = 16 // When failed to display the toast
}
对于 android,您可以在样式Snackbar
或Notification
样式之间进行选择。查看文档以获得控制权以根据需要执行通知!
推荐阅读
- javascript - 在javascript中“或”布尔值列表的最短方法
- html - 为什么按钮边框不会比#f0f0f0 更亮?
- python - Python 错误:命令不同步;你现在不能运行这个命令
- python - 在 django 中安装此库“pip install bcrypt”时出错
- ios - 如果元素为空白,则从结构中删除元素,因此它们不会显示在 UITableView 中
- tensorflow - 我如何知道哪个 GPU 足以解决问题?
- php - 从 PHP 表单自动填充扫描的 PDF
- azure-hybrid-connections - 如何删除显示在混合连接管理器 UI 应用程序中的混合连接?
- sql - 如何使用第三个表中的 ID 从第二个表的内容更新 MSSQL 表值以匹配记录?
- r - 使用 DLL 构建 R 包