0

Ich muss Aktionstasten in lokaler Benachrichtigung in iOS zeigen. Ich erhalte die Benachrichtigung, aber es gibt keine Aktionsschaltflächen. Könnten Sie mir bitte sagen, was ich falsch mache? Hier ist mein Code:Xamarin bildet lokale iOS-Benachrichtigungsschaltflächen

 var category = new UIMutableUserNotificationCategory(); 

     var okAction = new UIMutableUserNotificationAction 
     { 
      Identifier = "ok", 
      Destructive = false, 
      Title = "OK", 
      ActivationMode = UIUserNotificationActivationMode.Background, 
      AuthenticationRequired = false 
     }; 

     var delayAction = new UIMutableUserNotificationAction 
     { 
      Identifier = "delay", 
      Destructive = false, 
      Title = "Отложить", 
      ActivationMode = UIUserNotificationActivationMode.Background, 
      AuthenticationRequired = false 
     }; 

     var categoryIdentifier = "pills.category"; 
     category.Identifier = categoryIdentifier; 
     category.SetActions(new UIUserNotificationAction[] { delayAction, okAction }, UIUserNotificationActionContext.Minimal); 
     category.SetActions(new UIUserNotificationAction[] { delayAction, okAction }, UIUserNotificationActionContext.Default); 

     var categories = new NSSet(new NSObject[] {category}); 

     var notificationSettings = UIUserNotificationSettings.GetSettingsForTypes(
      UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound, categories 
     ); 
     UIApplication.SharedApplication.RegisterUserNotificationSettings(notificationSettings); 


     var next = new TimeSpan(start.Ticks); 

     var count = Math.Round(24.0/interval.TotalHours); 

     for (int i = 0; i < count; i++) 
     { 
      var notification = new UILocalNotification 
      { 
       AlertAction = title, 
       AlertBody = text, 
       SoundName = UILocalNotification.DefaultSoundName, 
       ApplicationIconBadgeNumber = 0, 
       FireDate = NSDate.FromTimeIntervalSinceNow(next.TotalSeconds), 
       RepeatInterval = NSCalendarUnit.Day, 
       Category = categoryIdentifier 
      }; 
      UIApplication.SharedApplication.ScheduleLocalNotification(notification); 

      next = next.Add(interval); 
     } 
    } 

P. S. Ich benutze iOS 11 Emulator.

Antwort

0

Sie müssen nach unten wischen, um die Schaltflächen zu sehen.

Die folgende gif zeigt Wie in Background und Lock Screen

enter image description here

bedienen
Verwandte Themen