当我将此数据发送到我的 Android 设备时,它可以正常工作,并且会打开与“click_action”相对应的事件。我还可以收集“标题”和“价格”等数据并将它们放入字符串中。
但是,对于 iOS,我无法弄清楚如何从通知中收集数据,然后在单击通知时打开某个 View Controller 。
非常感谢任何帮助。多谢。
最佳答案
使用didReceiveRemoteNotification
是当前处理触摸事件的方法。
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
...
if let userInfo = launchOptions?[UIApplicationLaunchOptionsKey.remoteNotification] {
NSLog("[RemoteNotification] applicationState: \(applicationStateString) didFinishLaunchingWithOptions for iOS9: \(userInfo)")
//TODO: Handle background notification
}
return true
}
Notes: NO notification will appear on device’s notification center when receiving remote notification in active state. You may need to present your notification in your own way. If you need to present or push view controllers based on the content of notification. You need to save the content of notification and handle it until UIs are all ready.
由 FCM on Swift 3 提供
关于ios - 从FCM通知数据IOS中检索数据并打开 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52631459/