2

In apple push notification I am sending emojis in payload and they as showing as Unicode characters in notification.

Using ApnsPayloadBuilder to create payload and sending message like

payloadBuilder.setAlertBody(new String(msg, "UTF-8"));

I am getting this message from our database and emojis are storing like

nice \u270c\ufe0f\ud83d\udc4d

in db.

How do I solve this issue?

Peyman Mohamadpour
  • 17,954
  • 24
  • 89
  • 100
user2423768
  • 185
  • 1
  • 12

1 Answers1

0

You need to send the unicode character in the payload, not as an emoji. So for the winking face in your payload, sent it as \ue405 not as . You can use this website for finding the unicode translations for the emojis http://www.easyapns.com/category/just-for-fun

naomimichiko
  • 693
  • 4
  • 10
  • thanks for the answer but it does not work i pass it as \ue405 in payload but it is not changing to emoji in phone. Is there any other thing that i am missing? – user2423768 Jun 03 '16 at 07:00
  • hm could you add exactly what the payload contains now? using /ue405 directly in an NSString should automatically convert it to the emoji. In your example above the "nice \u270c\ufe0f\ud83d\udc4d" string would not compile because only the first one /u270c is an emoji the others are not recognized, which could also be a source of your issues. Check your emoji unicode's against the link I posted in my answer – naomimichiko Jun 07 '16 at 16:21
  • Hi {"alert":"alex left a commented on Ray LaMontagne - Trouble: \"good\" \/u270c","badge":1} this is my payload that sent in push. As you said i only pass /u270c but it still fails. Unable to under stand the issue. – user2423768 Jun 13 '16 at 13:50
  • When I try to use that string in iOS I get the error "Unknown escaped sequence \/". You do not need this first \ just put the emoji in as /u270c – naomimichiko Jun 15 '16 at 17:26