Ich möchte dem Benutzer eine Benachrichtigung anzeigen, aber Titel ist immer null. Problem ist notification.AlertAction ist null, bevor die Benachrichtigung angezeigt wird.Lokale Benachrichtigung AlertAction immer Null in Xamarin iOS
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;
}
und ich bin die Einrichtung sowohl notification.AlertAction und 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);
}
}
ich dieses Tutorial folgenden wurde: https://developer.xamarin.com/guides/ios/application_fundamentals/notifications/local_notifications_in_ios_walkthrough/