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

3

4

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

Klan answered 14/8, 2020 at 9:31 Comment(2)
Could you send request to some http endpoints like mockbin.org to find the difference? Like curl -X POST mockbin.org/request -H 'Content-type: application/json' -d '{"emoji":"\uD83D\uDE0A"}'. Send request by your backend and postman.Spirochete
Where are your user's emoji's stored? What kind of object is the user.getEmoji(), is your database attempting to translate and store the emoji. You'll need to provide more information from your code and your how your database is structured for an accurate answer.Whirlpool
M
1

Try this string:

"\u{D83D}\u{DE0A}"
Minny answered 14/8, 2020 at 9:41 Comment(0)
M
0

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.

Mongolism answered 20/8, 2020 at 13:2 Comment(0)
A
0

"\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.

Atrioventricular answered 23/8, 2020 at 14:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.