How to let iOS 12 Notification Extension custom UI

2019-08-05 12:02发布

问题:

I have created my own Notification Extension custom UI with iOS 12 and added 2 buttons in it. Now I want to tap any of the buttons to launch the app with the app being aware of which buttons was tapped. My problem is, either the notification-extension captures the tapping of button but stays in the custom UI without launching the app, or it does not capture the tapping of button while being able to launch the app. Is there any solution then? Thanks!

回答1:

Now I want to tap any of the buttons to launch the app with the app being aware of which buttons was tapped

Your button inside the interface can summon the app by telling the extension context to performNotificationDefaultAction, but this is no different from the user tapping on the background of the interface.

If you really need a button that summons the app and identifies itself to the app, you need to use an action button (a UNNotificationAction).