How to open iOS app when Push Notification custom button clicked?

3.1k Views Asked by At

I added some button into the iOS Push notification, e.g., I customized the Push Notification Banner/Alerts with some custom buttons, which I'd like to open the app.

Currently when I click the Banner/"Open" button of Alert dialog, the app runs successfully.

I want to add opening app event programmatically.

PS. It's about the interactive Push Notification. And on my research there isn't answer relevant to this question.

1

There are 1 best solutions below

2
On BEST ANSWER

Correction as Sudhan points out:

The UIUserNotificationAction objects that you are going to add to your UIUserNotificationCategory have a method activationMode, it can take constant UIUserNotificationActivationModeForeground

yourNotifificationAction.activationMode=UIUserNotificationActivationModeForeground

When the user presses the action button, app will launch in foreground and call this method on the appDelegate:

-(void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void (^)())completionHandler