What is the best practice for sending notifications with emoji, how should the payload look like?
Is there any parsing required to be done in the app to display emojis properly, or it just works out of the box if emojis are formatted properly?
I tried to send this emoji and tried various formats: http://www.charbase.com/1f602-unicode-face-with-tears-of-joy
the payload looked something like this:
"payload": {
"message": "U+1F602 \ud83d\ude02 😂 😂 f0 9f 98 82",
"title": "Hello",
"id": 123,
}
This is how app displays the notification:
@Override
protected void onHandleIntent(Intent intent) {
Bundle extras = intent.getExtras();
GCMPayload payload = new GCMPayload(
extras.getString("title"),
extras.getString("message"),
Strings.convertToLong(extras.getString("id")),
);
sendNotification(this, payload);
}
}
And within sendNotification method, the notification content text is set like this:
NotificationCompat.Builder builder =
new NotificationCompat.Builder(context)
.setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE)
.setContentTitle(payload.getTitle())
.setContentText(payload.getMessage())
.setStyle(new NotificationCompat.BigTextStyle().bigText(payload.getMessage()));
The emojis don't get displayed, their codes get displayed instead. Which encoding should be used? What else needs to be done in order to display emojis correctly?