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
curl -X POST mockbin.org/request -H 'Content-type: application/json' -d '{"emoji":"\uD83D\uDE0A"}'
. Send request by your backend and postman. – Spirocheteuser.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