[英]Parse to Firebase enhanced push notifications
我正在將Parse遷移到Firebase,但在增強的推送通知方面遇到了麻煩。
解析數據(iOS端)就像:
{"ast":
{"alert": {
{"body": "body_test",
"title": "title_test",
"description": "description",
"endpoint-proposal": "https://.."
"launch-image": "https://..."
},
"sound": "chime",
...
}
使用Firebase API時, ast標簽是['notification'] ['body'] 。
如果我發送
['notification']['body'] = 'Hello'
它可以完美運行並生成以下推送:
{"ast":
{"alert": "Hello"}
}...
因此,這里的問題是,我需要在該標簽(警報)中發送字典,但由於Firebase將值設置為字符串,所以無法執行此操作。
python中的示例:
alert = dict()
alert['title'] = 'title'
alert['description'] = 'description'
alert['endpoint-proposal'] = 'https://..'
alert['launch-image'] = 'https://..'
fcm_payload['notification']['body'] = alert
send_push()
在iOS方面,我得到:
[AnyHashable("gcm.message_id"): 0:123456789,
AnyHashable("aps"): {
alert = "{\"body\": \"body\",
\"launch-image\": \"https://...\",
\"endpoint-proposal\": \"https://...\",
\"description\": \"description\",
\"title\": \"title\"}";
}]
始終作為字符串:S
有什么方法可以將警報發送為dict?
json.loads()應該給你一個字典。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.