Notification not displayed with action buttons when app is killed ios
Solution 1:
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.
private func setNotificationCategories() {
let likeAction = UNNotificationAction(identifier: "like", title: "Like", options: [])
let replyAction = UNNotificationAction(identifier: "reply", title: "Reply", options: [])
let archiveAction = UNNotificationAction(identifier: "archive", title: "Archive", options: [])
let ccommentAction = UNTextInputNotificationAction(identifier: "comment", title: "Comment", options: [])
let localCat = UNNotificationCategory(identifier: "category", actions: [likeAction], intentIdentifiers: [], options: [])
let customCat = UNNotificationCategory(identifier: "recipe", actions: [likeAction,ccommentAction], intentIdentifiers: [], options: [])
let emailCat = UNNotificationCategory(identifier: "email", actions: [replyAction, archiveAction], intentIdentifiers: [], options: [])
UNUserNotificationCenter.current().setNotificationCategories([localCat,
customCat, emailCat])
}
And I Updated your code please check this
UNNotificationCategory *modifyCategory = [UNNotificationCategory categoryWithIdentifier:CYLInviteCategoryIdentifier actions:@[] intentIdentifiers:@[] options:UNNotificationCategoryOptionNone];
UNNotificationAction* snoozeAction = [UNNotificationAction
actionWithIdentifier:@"ACCEPT_ACTION"
title:@"Accept"
options:[]];
UNNotificationAction* stopAction = [UNNotificationAction
actionWithIdentifier:@"DECLINE_ACTION"
title:@"Decline"
options:[]];
UNNotificationCategory* actionCategory = [UNNotificationCategory
categoryWithIdentifier:@"INCOMING_CALL"
actions:@[snoozeAction, stopAction]
intentIdentifiers:@[]
options:[]];
[center setNotificationCategories:[NSSet setWithObjects: modifyCategory, actionCategory,
nil]];
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