Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS 10未通知操作从后台打开应用程序_Ios_Notifications_Action_Application Lifecycle_Usernotifications - Fatal编程技术网

iOS 10未通知操作从后台打开应用程序

iOS 10未通知操作从后台打开应用程序,ios,notifications,action,application-lifecycle,usernotifications,Ios,Notifications,Action,Application Lifecycle,Usernotifications,当用户收到通知且我的应用程序处于后台时,我如何打开我的应用程序?当然,点击通知本身会打开应用程序,但如何使用自定义通知操作来处理它呢 我已经实现了UnuseNotificationCenterDelegate和userNotificationCenter(u,didReceive,…) 只需要一个代码,可以打开我的应用程序并执行特定操作(例如转到特定视图) 如果通知处理程序能够识别该通知并打开iPhone应用程序或Apple Watch应用程序,这将非常好。好的,我已经找到了解决方案。我们必须设

当用户收到通知且我的应用程序处于后台时,我如何打开我的应用程序?当然,点击通知本身会打开应用程序,但如何使用自定义通知操作来处理它呢

我已经实现了UnuseNotificationCenterDelegate和userNotificationCenter(u,didReceive,…)

只需要一个代码,可以打开我的应用程序并执行特定操作(例如转到特定视图)


如果通知处理程序能够识别该通知并打开iPhone应用程序或Apple Watch应用程序,这将非常好。

好的,我已经找到了解决方案。我们必须设置UNNotificationActionOptions:)

Swift 3/4示例(因为我不知道如何设置此选项):重要的是
UNNotificationAction
UNNotificationAction选项

let myAction = UNNotificationAction(identifier: "myActionIdentifier", title: "MyAction", options: [.foreground])

关于这个问题和建议的答案,我注意到上面说:“使用此选项进行需要用户与您的应用程序进一步交互的操作。不要使用此选项只是为了将您的应用程序推向前台。”您知道这有什么区别,以及它为什么重要吗?
let myAction = UNNotificationAction(identifier: "myActionIdentifier", title: "MyAction", options: [.foreground])