3

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.

AL.
  • 36,815
  • 10
  • 142
  • 281
MPe
  • 430
  • 6
  • 23

2 Answers2

1

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!

MPe
  • 430
  • 6
  • 23
1

With application/json;charset=UTF-8 should work. Had the same issue, that adding charset=UTF-8 to the Content-Type solved it.

David Magalhães
  • 750
  • 4
  • 10
  • 27