问题
I tried for a while to send a FCM Notification with special characters like this:
curl --header "Authorization: key=Auth-CODE"
--header Content-Type:"application/json
for JSON; application/x-www-form-urlencoded;charset=UTF-8"
-d '{"to":"token","notification":{"title":"München",
"body":"Test Content with äöü",
"icon":"images/icon-192x192.png"}}'
https://fcm.googleapis.com/fcm/send
The notification I'll get looks like this:
Mnchen
Test Content with
Can anybody please guide me to the right direction? Thanks a lot!
EDIT
The client is a browser, because the app is a web-App.
回答1:
With application/json;charset=UTF-8
should work. Had the same issue, that adding charset=UTF-8
to the Content-Type
solved it.
回答2:
According to @LangHoang I tried to use Base64 encode and decode to get a special character support!
<?php
base64_encode ($string);
and decode the response in javascript (firebase-messaging-sw.js)
body:b64DecodeUnicode(payload.notification.body)
And now everything works very well!
来源:https://stackoverflow.com/questions/41115769/how-to-send-a-firebase-cloud-messaging-notification-with-special-characters-like