I've done following code to display action buttons while notification comes using one signal. But when app is killed notification is not coming. It's working properly in background/foreground mode. But when app is not in tray even notification stop coming. Without action buttons it's working perfectly.
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
center.delegate = self;
[center requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge) completionHandler:^(BOOL granted, NSError * _Nullable error)
{
if( !error ) {
[[UIApplication sharedApplication] registerForRemoteNotifications];
NSLog( @"Push registration success." );
} else {
NSLog( @"Push registration FAILED" );
}];
UNNotificationCategory *modifyCategory = [UNNotificationCategory categoryWithIdentifier:CYLInviteCategoryIdentifier actions:@[] intentIdentifiers:@[] options:UNNotificationCategoryOptionNone];
UNNotificationAction* snoozeAction = [UNNotificationAction
actionWithIdentifier:@"ACCEPT_ACTION"
title:@"Accept"
options:UNNotificationActionOptionForeground];
UNNotificationAction* stopAction = [UNNotificationAction
actionWithIdentifier:@"DECLINE_ACTION"
title:@"Decline"
options:UNNotificationActionOptionDestructive];
UNNotificationCategory* actionCategory = [UNNotificationCategory
categoryWithIdentifier:@"INCOMING_CALL"
actions:@[snoozeAction, stopAction]
intentIdentifiers:@[]
options:UNNotificationCategoryOptionNone];
[center setNotificationCategories:[NSSet setWithObjects: modifyCategory, actionCategory,
nil]];
There is two way to achieve this action handling in Push Notification. 1) Is simple register your UNUserNotificationCenter which you are currently using but you are facing issues with action button not showing in killed mode.
So please check your payload user info dictionary identifier & category with your configuration which you shared.
Following is my code please check this Swift code.
And I Updated your code please check this
change is just don't set option.
2)Use Notification extension You can design attractive push notification. for that, I suggest prefered this blog iOS Remote Push Notifications