watchOS远程通知与自定义按钮

时间:2016-08-03 15:37:28

标签: ios watch-os-2

我已经尝试过在收到远程通知时尝试显示自定义按钮。我的动态控制器确实正在加载但只有Dismiss按钮显示。这是我的PushNotificationPayload.apns文件:

{
"aps": {
    "alert": {
        "body": "Hi! How you doing? This is a test message. Press 'Reply' button to reply. Thanks!",
        "title": "Petya"
    },
    "category": "myCategory"
},

"WatchKit Simulator Actions": [
   {
   "title": "Reply",
   "identifier": "replyPressed"
   }
]

}

这是我在NotificationController.swift中的代码:

override func didReceiveRemoteNotification(remoteNotification: [NSObject : AnyObject], withCompletion completionHandler: ((WKUserNotificationInterfaceType) -> Void)) {
    if let remoteaps:NSDictionary = remoteNotification["aps"] as? NSDictionary{
        print(remoteaps)
        if remoteaps.objectForKey("alert") != nil {
            let title = remoteaps.valueForKey("alert") as? String
            self.alertLabel.setText(title)
        }
    }
    completionHandler(.Custom)
}

我读过的所有内容都应该可以使用但是“回复”按钮不显示。我错过了什么?

0 个答案:

没有答案