【问题标题】:How to get the topic out of a Firebase message notification in iOS?如何从 iOS 中的 Firebase 消息通知中获取主题?
【发布时间】:2017-02-13 15:48:08
【问题描述】:

在 Android 中,您可以使用 getFrom() 从通知中读取主题。 谁能帮助我如何在 iOS 中了解这一点?

【问题讨论】:

    标签: ios swift firebase firebase-cloud-messaging firebase-notifications


    【解决方案1】:

    Android 中的 getFrom() 函数在 iOS 中没有对应的功能。

    作为一种解决方法,您可以在 data 有效负载中添加自定义键值对,作为您要向其发送消息的主题的名称。

    这也是answer 中提到的建议解决方法。

    【讨论】:

      【解决方案2】:

      在 Appdelegate 中。实现下面的函数,你可以在userInfo中得到它。

      func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject],
                           fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {
                  // Access userInfo
                  let aps = userInfo["aps"] as? NSDictionary
                  if let aps = aps {
                      let alert = aps["alert"] as! NSDictionary
                      let body = alert["body"] as! String
                      let title = alert["title"] as! String                    
                  }
      
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2015-08-01
        • 2019-02-10
        • 1970-01-01
        • 1970-01-01
        • 2017-08-28
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多