Chirag Shah
Chirag Shah

Reputation: 3016

Emoji does not display in push Notification instead it display question mark or display unicode

Emoji appears as a unicode characters in push notifications. i-e : if we have text like "\ud83d\ude0a". This is the code of SMILE EMOJI which displays as unicode characters or some time it display question mark in push notification.

Is there anything else need to do in code or on server side. ? Any help would be appreciated. we are using java at backend side

Json example :

{
   "to": "c2rMPP0eK04Ro0FJDgMflH:APA91bEydhoB0VU5W6PxJLnIRoFqOk5npEjlWzBlvdyBlX1Cp72t0bYxDyepP5Z9mWFQ2XYeUPw8PDo3QqT6Anh27wqnkBRbabTYKn0tByOZOMU6oRlrGur-efxN9_-8LlOmDZceg9Kl",
   "notification": {
      "body": "Hello",
      "title": "This is done manually. \uD83D\uDE0A"
   }
}

We try this things

byte[] emojis = user.getEmoji().getBytes();
String emojisAsString = new String(emojis, StandardCharsets.UTF_8);
Integer emojiCodePoint = emojisAsString.codePointAt(emojisAsString.offsetByCodePoints(0,0));
char emojiChars[] = {Character.highSurrogate(emojiCodePoint), Character.lowSurrogate(emojiCodePoint)};

Note : If we fire this things from postman then it is working but not working when it fire from backend

Upvotes: 4

Views: 2712

Answers (3)

Akshay
Akshay

Reputation: 832

"\uD83D\uDE0A" or "\u{D83D}\u{DE0A}" is not encoded emoji.

You should encoded like \u{ and }:

"\u{1F600} \u{1F616}"

Refer link:

Emoji unicodes

Unicode in iOS

It works on playground. Check if it works on notification panel.

Upvotes: 0

PRADEEP CHOUDHARY
PRADEEP CHOUDHARY

Reputation: 46

If you are reading from DB, try updating your DB driver. Like if you are using MySQL, use 'mysql-connector-java:5.1.47' or higher.

Upvotes: 0

Sergio
Sergio

Reputation: 1912

Try this string:

"\u{D83D}\u{DE0A}"

Upvotes: 1

Related Questions