XCode 7, Swift 2. (甚至不要从我这里开始,这也不是我最喜欢的一组约束)
所以我正在使用node-apn发送数据(非常感谢那些人!)。我正在使用(pushkit 选项)*.voip
主题,我得到了所有的工作。我可以看到我的设备上收到了通知(对libimobiledevice 大喊大叫)。
在我的服务器上撰写笔记时,我正在做
var note = new apn.Notification();
note.topic = 'mine.voip';
note.payload = {
message: 'text',
somethingElse: 'this other one '
payload: {
k1: v1,
k2: {
k3: v2
}
}
};
我应该如何获取我的有效负载对象?遵循一些(第 3 方)pushkit 示例(可能是1?
func pushRegistry(registry: PKPushRegistry!, didReceiveIncomingPushWithPayload payload: PKPushPayload!, forType type: String!) {
let payloadDict = payload.dictionaryPayload["aps"] as? Dictionary<String, String>
let message = payloadDict?["alert"]
}
我试着模仿它
let myWeirdPayload = payload.dictionaryPayload["payload"] as? Dictionary<String, String>
甚至
let myWeirdPayload = payload.dictionaryPayload["payload"] as? Dictionary<String, Any>
但那些不起作用(我明白了nil
)。
我该怎么做?