通知をユーザーに表示したいのですが、タイトルは常にnullです。問題はnotification.AlertActionが通知を表示する前にnullです。ローカル通知Xamarin iOSでは常にAlertActionがnullです
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);
}
}
私は、このチュートリアルの次ました:https://developer.xamarin.com/guides/ios/application_fundamentals/notifications/local_notifications_in_ios_walkthrough/