【问题标题】:getting push data in swift 3在 swift 3 中获取推送数据
【发布时间】:2017-08-19 12:24:22
【问题描述】:

我需要一些帮助来获取内部推送数据。

在我的应用委托文件中,我有以下内容:

// Push notification received
func application(_ application: UIApplication, didReceiveRemoteNotification data: [AnyHashable : Any]) {
    // Print notification payload data
    print("Push notification received: \(data)")
}

结果如下:

Push notification received: [AnyHashable("aps"): {
Link = "http://www.website.com.dll?i.user8=App&id=374941&mobileOnly=true";
alert = "New survey";
}]

我将如何从数据中获取价值链接

谢谢

【问题讨论】:

    标签: ios swift3 xcode8


    【解决方案1】:

    您可以获得如下推送数据。

     func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
    
         let dictPayload = userInfo as NSDictionary
    
         if let data = dictPayload.value(forKey: "aps") as? NSDictionary {
              let link = data.value(forKey: "Link") as? String
              print(link)
          }
        print("Push notification received: \(data)")
    }
    

    【讨论】:

      猜你喜欢
      • 2017-08-16
      • 2017-01-26
      • 2018-06-15
      • 1970-01-01
      • 2017-07-08
      • 2017-10-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多