samedi 25 juin 2016

ios 8 interactive notifications not showing actions

This is my code to register Interactive Notifications for ios8 : + (void)registerInteractiveNotifications { UIMutableUserNotificationCategory *corideInviteCategory = [self corideInviteCategory]; UIMutableUserNotificationCategory *riderInviteCategory = [self riderInviteCategory]; NSSet *categories = [NSSet setWithObjects:corideInviteCategory, riderInviteCategory, nil]; UIUserNotificationType types = (UIUserNotificationTypeAlert| UIUserNotificationTypeSound| UIUserNotificationTypeBadge); UIUserNotificationSettings *settings; settings = [UIUserNotificationSettings settingsForTypes:types categories:categories]; [[UIApplication sharedApplication] registerUserNotificationSettings:settings]; } + (UIMutableUserNotificationCategory *)riderInviteCategory { UIMutableUserNotificationAction *accept; accept = [[UIMutableUserNotificationAction alloc] init]; [accept setActivationMode:UIUserNotificationActivationModeForeground]; [accept setTitle:@"Accept"]; [accept setIdentifier:RiderInviteAccept]; [accept setDestructive:NO]; [accept setAuthenticationRequired:NO]; UIMutableUserNotificationAction *decline; decline = [[UIMutableUserNotificationAction alloc] init]; [decline setActivationMode:UIUserNotificationActivationModeForeground]; [decline setTitle:@"Decline"]; [decline setIdentifier:RiderInviteDecline]; [decline setDestructive:YES]; [decline setAuthenticationRequired:NO]; UIMutableUserNotificationCategory *actionCategory; actionCategory = [[UIMutableUserNotificationCategory alloc] init]; [actionCategory setIdentifier:RiderInviteCategory]; [actionCategory setActions:@[decline, accept] forContext:UIUserNotificationActionContextDefault]; [actionCategory setActions:@[decline, accept] forContext:UIUserNotificationActionContextMinimal]; return actionCategory; } + (UIMutableUserNotificationCategory *)corideInviteCategory { UIMutableUserNotificationAction *accept; accept = [[UIMutableUserNotificationAction alloc] init]; [accept setActivationMode:UIUserNotificationActivationModeForeground]; [accept setTitle:@"Accept"]; [accept setIdentifier:CorideInviteAccept]; [accept setDestructive:NO]; [accept setAuthenticationRequired:NO]; UIMutableUserNotificationAction *decline; decline = [[UIMutableUserNotificationAction alloc] init]; [decline setActivationMode:UIUserNotificationActivationModeForeground]; [decline setTitle:@"Decline"]; [decline setIdentifier:CorideInviteDecline]; [decline setDestructive:YES]; [decline setAuthenticationRequired:NO]; UIMutableUserNotificationCategory *actionCategory; actionCategory = [[UIMutableUserNotificationCategory alloc] init]; [actionCategory setIdentifier:CorideInviteCategory]; [actionCategory setActions:@[decline, accept] forContext:UIUserNotificationActionContextDefault]; [actionCategory setActions:@[decline, accept] forContext:UIUserNotificationActionContextMinimal]; return actionCategory; } What happens is : when i delete the app and install again, the 2 action buttons (when I pull down the notification banner, or swipe left in notification center) appears. But after a while ( i'm not really sure what cause it ), they stop appearing although i keep sending the same notification. This is my notification content: {"aps":{"alert":"test","category":"coride_invite"},"journey_id":100} Can anyone shed some light please ? Thanks

Aucun commentaire:

Enregistrer un commentaire