gpt4 book ai didi

ios - 从 [AnyHashable : Any] Push notification 获取数据

转载 作者:行者123 更新时间:2023-11-30 11:25:05 24 4
gpt4 key购买 nike

我正在尝试解析推送通知中的next_question_detail,但全部失败:

for data in notification.request.content.userInfo {
print(data)
}
//Output

(key: AnyHashable("next_question_detail"), value: {"question_ar":"مرحبا","question":"hi","id":"5"})
(key: AnyHashable("errorCode"), value: 0)
(key: AnyHashable("google.c.a.e"), value: 1)
(key: AnyHashable("body"), value: )
(key: AnyHashable("userId"), value: 4)
(key: AnyHashable("title"), value: Wit)
(key: AnyHashable("gcm.message_id"), value: 0:1528865771984376%fa33e8cdfa33e8cd)
(key: AnyHashable("aps"), value: {
alert = {
body = "";
title = Wit;
};
badge = 0;
sound = default;
})




if let aps = notification.request.content.userInfo["next_question_detail"]! as? NSDictionary {
print("aps",aps)
}


if let data = notification.request.content.userInfo["next_question_detail"] as? [String: String] {
print("array",data)
}

最佳答案

您可以使用以下代码来完成此操作 -

if let userInfo = userInfo as? [String: Any] {
guard let next_question_detail = userInfo["next_question_detail"] as? [String: Any] else {
return
}
print(next_question_detail)
}

关于ios - 从 [AnyHashable : Any] Push notification 获取数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50829397/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com