actions et catégories n'apparaissent pas dans UILocalNotification dans iOS

J'ai ce qui suit, que je crois de la documentation de pomme ici est tout ce dont j'ai besoin pour avoir une catégorie pour UILocalNotification :

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { UIMutableUserNotificationAction *acceptAction = [[UIMutableUserNotificationAction alloc] init]; // Define an ID ssortingng to be passed back to your app when you handle the action acceptAction.identifier = @"ACCEPT_IDENTIFIER"; // Localized ssortingng displayed in the action button acceptAction.title = @"Accept"; // If you need to show UI, choose foreground acceptAction.activationMode = UIUserNotificationActivationModeBackground; // Destructive actions display in red acceptAction.destructive = NO; // Set whether the action requires the user to authenticate acceptAction.authenticationRequired = NO; // First create the category UIMutableUserNotificationCategory *inviteCategory = [[UIMutableUserNotificationCategory alloc] init]; // Identifier to include in your push payload and local notification inviteCategory.identifier = @"INVITE_CATEGORY"; // Add the actions to the category and set the action context [inviteCategory setActions:@[acceptAction] forContext:UIUserNotificationActionContextDefault]; // Set the actions to present in a minimal context [inviteCategory setActions:@[acceptAction] forContext:UIUserNotificationActionContextMinimal]; NSSet *categories = [NSSet setWithObjects:inviteCategory, nil]; UIUserNotificationSettings* notificationSettings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound categories:categories]; [[UIApplication sharedApplication] registerUserNotificationSettings:notificationSettings]; // Handle launching from a notification UILocalNotification *localNotif = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey]; if (localNotif) { NSLog(@"Recieved Notification %@",localNotif); } return YES; } 

Voici comment je construis ma notification locale:

 NSDate *dateChosen = [self.reminderDatePicker date]; NSCalendar *calendar = [NSCalendar currentCalendar]; NSDateComponents *components = [calendar components:(NSCalendarUnitHour | NSCalendarUnitMinute) fromDate:dateChosen]; NSInteger hour = [components hour]; NSInteger minute = [components minute]; // NSCalendar *calendar = [NSCalendar currentCalendar]; // NSDateComponents *components = [[NSDateComponents alloc] init]; [components setDay: 3]; [components setMonth: 7]; [components setYear: 2012]; [components setHour: hour]; [components setMinute: minute]; [components setSecond: 0]; [calendar setTimeZone: [NSTimeZone defaultTimeZone]]; NSDate *dateToFire = [calendar dateFromComponents:components]; UILocalNotification *localNotification = [[UILocalNotification alloc] init]; localNotification.fireDate = dateToFire; [localNotification setRepeatInterval: kCFCalendarUnitDay]; NSLog(@"Notification will be shown on: %@ ",localNotification.fireDate); localNotification.userInfo = [[NSDictionary alloc] initWithObjectsAndKeys:self.dayPeriod, @"name", nil]; localNotification.timeZone = [NSTimeZone defaultTimeZone]; localNotification.alertBody = alertMessage; localNotification.alertAction = NSLocalizedSsortingng(@"View details", nil); localNotification.repeatInterval = NSDayCalendarUnit; localNotification.soundName = UILocalNotificationDefaultSoundName; localNotification.applicationIconBadgeNumber = -1; [[UIApplication sharedApplication] scheduleLocalNotification:localNotification]; 

Il affiche simplement la notification par défaut avec un button de rejet et pas mon button d'acceptation.

Comment puis-je get ce button "Accepter" pour afficher sur ma notification locale?

La seule chose qui vous manque dans votre corps principal de code pour UILocalNotification dit explicitement qu'il s'agit d'une notification par catégorie.

Ajoutez la propriété category à votre notification:

 localNotification.category = @"INVITE_CATEGORY";