解码推送通知PKPushPayload AnyHashable时出错

时间:2018-12-20 18:56:50

标签: ios swift push-notification

我在下面的代码中解码AnyHashable,看来我做错了。 twiFrom为零。任何人都可以纠正错误并提供正确的解码方法吗? Tx

有效载荷:

payload.dictionaryPayload:[AnyHashable(“ aps”):{ },AnyHashable(“ twi_to”):客户端:client3,AnyHashable(“ twi_from”):客户端:client2,AnyHashable(“ twi_account_sid”):A959d,AnyHashable(“ twi_bridge_token”):eyJraWjoyI,AnyHashable(_twi_message: .voice.call,AnyHashable(“ twi_call_sid”):CAf56,AnyHashable(“ twi_message_id”):RU6]

func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void) {

    if (type == PKPushType.voIP) {

        print("payload.dictionaryPayload: \(payload.dictionaryPayload)")
        let twiFrom = payload.dictionaryPayload["twi_from"] as? Dictionary<String, String> // ERROR: Nil
        let fromClient = twiFrom?["client"]
        print ("fromClient: \(fromClient!)")
}

0 个答案:

没有答案