【发布时间】:2017-08-25 20:22:30
【问题描述】:
这是我的didReceiveRemoteNotification 代码:
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any]) {
print("notification recieved: \(userInfo)")
// Pass push notification payload to the shared model
let payload: NSDictionary = userInfo as NSDictionary
if let variable = payload["variable"] as? String {
NotificationManager.SharedInstance.handleVariableNotification(variable)
}
}
当我从应用程序外部单击通知时,代码可以正常工作并正确执行我想要的操作。
我的问题是:如果我在当前处于应用程序中时收到通知,它仍会运行通知中的代码并覆盖用户当前在应用程序中执行的任何操作
我只希望代码在用户点击通知时运行,而不是在我已经在应用程序中时自动运行。
提前致谢!
【问题讨论】:
标签: ios swift swift3 push-notification notifications