ios - 从FCM通知数据IOS中检索数据并打开 View Controller

标签 ios swift firebase firebase-cloud-messaging

当我将此数据发送到我的 Android 设备时,它可以正常工作,并且会打开与“click_action”相对应的事件。我还可以收集“标题”和“价格”等数据并将它们放入字符串中。

但是,对于 iOS,我无法弄清楚如何从通知中收集数据,然后在单击通知时打开某个 View Controller 。

Notification Data

非常感谢任何帮助。多谢。

最佳答案

使用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/

相关文章:

swift - 表格 View 单元格在滚动 Swift 时改变颜色

javascript - 在javascript中运行时动态从firebase实时数据库获取数据

android - Firebase Auth - GoogleAuthProvider 和 FacebookAuthProvider 正在取代 EmailAuthProvider

ios - 我们如何默认选择表列表行

ios - 如何设置 PersistantStore 的自定义路径

ios - Swift 强制我在调用下一个类的对象时使用 self

ios - UIPageViewControllerDataSource - 未调用 segueForUnwindingToViewController

iphone - 如何向服务器写入数据?

ios - 后退按钮在 UINavigationController 中奇怪地消失但继续工作

swift - 如何检测观察者何时完成 Firebase