我正在將解析遷移到Firebase,並且遇到增強推送通知問題。解析爲Firebase增強推送通知
解析數據(iOS的側)是象:
{"ast":
{"alert": {
{"body": "body_test",
"title": "title_test",
"description": "description",
"endpoint-proposal": "https://.."
"launch-image": "https://..."
},
"sound": "chime",
...
}
與火力地堡API工作的AST標籤是[ '通知'] [ '體']。
如果我送
['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
有什麼方法來發送警報的字典?
已經過測試。無論如何,它始終將值設置爲字符串。 – giopromolla