本地通知不显示在模拟器中



新建项目使用插件。LocalNotification version 10.0.2

Xamarin的。表单版本5.0.0.2515

MainPage

中的代码
async void Button_Clicked(System.Object sender, System.EventArgs e)
{
try
{
var notification = new NotificationRequest
{
NotificationId = 100,
Title = "Test",
Description = "Test Description",
ReturningData = "Dummy data", // Returning data when tapped on notification.
Schedule =
{
NotifyTime = DateTime.Now.AddSeconds(5) // Used for Scheduling local notification, if not specified notification will show immediately.
}
};
await Plugin.LocalNotification.LocalNotificationCenter.Current.Show(notification);
}
catch(Exception ex)
{

没有发现异常,也没有提示,是什么问题?

您可以参考Forms官方文档中的本地通知示例。对于iOS,在应用程序可以向用户发送通知之前,应用程序必须在系统中注册,并且由于通知对用户具有侵入性,因此应用程序必须在发送通知之前明确请求权限。

您可以参考以下文件:

Xamarin中的本地通知。Forms | Microsoft

请求许可使用通知| Apple Developer

最新更新