C# 如何以Xamarin.Forms发出通知

C# 如何以Xamarin.Forms发出通知,c#,.net,xamarin,xamarin.forms,C#,.net,Xamarin,Xamarin.forms,如何使用XAML或C#代码在Xamarin.Forms中发出通知 我可以在Ios中与Xamarin.Forms一起使用它吗 看看精彩的 您可以简单地触发这样的通知 var notificator = DependencyService.Get<IToastNotificator>(); var options = new NotificationOptions() { Title = "Title", Descript

如何使用XAML或C#代码在Xamarin.Forms中发出通知


我可以在Ios中与Xamarin.Forms一起使用它吗

看看精彩的

您可以简单地触发这样的通知

var notificator = DependencyService.Get<IToastNotificator>();

var options = new NotificationOptions()
        {
            Title = "Title",
            Description = "Description"
        };
await notificator.Notify(options);

对于android,您可以在
Snackbar
Notification
样式之间进行选择。查看文档以获得控制权,以便按照您的要求执行通知

你想要真正的推送通知还是本地通知?@AlmirVuk a local实际上,你不能用xaml做通知。通知由操作系统管理,您只能提供它期望的值,并且操作系统本身将处理该表示。我们经常使用依赖项服务(或封装此服务的插件),从
C#
项目的共享代码调用它。有几个插件可用于帮助管理通知:@diegrafaelsouza okay thx,谢谢您的支持
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
}