我在下面的代码中解码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!)")
}