0

Je dois afficher les boutons d'action dans la notification locale dans iOS. J'obtiens la notification mais il n'y a pas de boutons d'action. Pourriez-vous s'il vous plaît me guider ce que je fais mal. Voici mon code:Xamarin forme des boutons de notification iOS locaux

 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); 
     } 
    } 

post-scriptum J'utilise l'émulateur iOS 11.

Répondre

0

Vous devez balayer vers le bas pour voir les boutons.

Le gif suivant montre Comment opérer dans Background et Lock Screen

enter image description here