接收到的推送模式在IOS上会是什么样子

时间:2016-07-29 09:47:27

标签: ios apple-push-notifications kinvey

我们正在使用kinvey业务逻辑来推送postSave上的通知: 以下是从订婚中发送的内容:

{
"aps": {
    "alert": "Hello World",
    "sound": "default"
},

}

1 个答案:

答案 0 :(得分:2)

aps结构作为嵌套对象传递到userInfo appDelegate方法中可用的didReceiveRemoteNotification对象上。您可以在Swift中使用它:

func application(application: UIApplication, didReceiveRemoteNotification   userInfo: [NSObject : AnyObject], fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {
    if let notification = userInfo["aps"] as? NSDictionary,
    let alert = notification["alert"] as? String {
        // do something with 'alert'

(来自http://www.intertech.com/Blog/push-notifications-tutorial-for-ios-9/的代码段)