【发布时间】:2017-07-31 19:19:08
【问题描述】:
我想向用户显示通知,但标题始终为空。问题是通知。在显示通知之前,AlertAction 为空。
public override void ReceivedLocalNotification(UIApplication application, UILocalNotification notification)
{
// notification.AlertAction is null!!! while notification.AlertBody is correct
UIAlertController okayAlertController = UIAlertController.Create(notification.AlertAction, notification.AlertBody, UIAlertControllerStyle.Alert);
okayAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
Window.RootViewController.PresentViewController(okayAlertController, true, null);
UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;
}
我同时设置了 notification.AlertAction 和 notification.AlertBody:
public class NotificationService_iOS : INotificationService
{
public void Notify(string title, string text)
{
var notification = new UILocalNotification();
notification.FireDate = NSDate.FromTimeIntervalSinceNow(0);
notification.AlertAction = title;
notification.AlertBody = text;
notification.ApplicationIconBadgeNumber = 1;
notification.SoundName = UILocalNotification.DefaultSoundName;
UIApplication.SharedApplication.ScheduleLocalNotification(notification);
}
}
【问题讨论】:
标签: xamarin xamarin.ios xamarin.forms uilocalnotification