I make an ios game. I need to add an advanced ios 10 notification with three actions (as UNNotificationAction ). One of the actions has to run my game. I have implemented the notification, actions and UNNotificationContentExtension class with didReceive function (with UNNotificationResponse argument). Everything works good: I have received my notification with actions. What I should do in didReceive function to run my game? My code:
func didReceive(_ response: UNNotificationResponse, completionHandler completion: @escaping (UNNotificationContentExtensionResponseOption) -> Void) {
switch (response.actionIdentifier) {
case "inGame":
// run game here!!!
case "sendAgain":
// some logic
case "cancel":
// another some logic
default:
completion(.dismiss)
}
}
Set activationMode
of the inGame
action to UIUserNotificationActivationModeForeground
. It will cause the action to open the game when user touches it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.