[英]How to run application within UNNotificationContentExtension
I make an ios game. 我做一个iOS游戏。 I need to add an advanced ios 10 notification with three actions (as UNNotificationAction ).
我需要添加带有三个操作的高级ios 10通知(如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).
我已经实现了通知,动作和UNNotificationContentExtension类didReceive功能(带UNNotificationResponse参数)。 Everything works good: I have received my notification with actions.
一切正常:我收到了有关操作的通知。 What I should do in didReceive function to run my game?
我应该在didReceive函数中运行我的游戏吗? 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
. 设置
activationMode
的的inGame
动作UIUserNotificationActivationModeForeground
。 It will cause the action to open the game when user touches it. 当用户触摸游戏时,它将导致动作打开游戏。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.