Emojis support in Apple push notification

I am working on an iPhone application called "INTERSTIZIO". In this, I implemented features such as chat between users. This user can send text, location, and text using the emojis character. If the application is not in open mode at the end of the receiver, then a push is generated from the backend and displayed on the receiver. I can display the message in push as "UserName: Hello ...", but I also want to display the emojis character, for example, "UserName: Hay :)" in the push message, so that anyone has an idea on how I can achieve of this type of push message using emojis code (for example, is there a smile for the apple code?)?

I followed the solution given in this link: http://code.iamcal.com/php/emoji/ But it returns the same code that I passed in the function. It works great on web pages, but not in a push message.

Here I attach one screenshot as it looks at my end. In it, you can see that I displayed a smiley and a lighting symbol, but it was displayed using HTML code, as shown below in the PHP script code:

$lightning = html_entity_decode('',ENT_NOQUOTES,'UTF-8'); //add this to the 'alert' portion of your APNS payload: $message = "You just got the {$lightning}SHOCKER{$lightning}!"; 

But in my case, I displayed the built-in emojis keyboard from apple and using the code below, I can get the emojis code:

 //store code of emojis at backend NSData *data = [txtspeech.text dataUsingEncoding:NSNonLossyASCIIStringEncoding]; NSString *valueUnicode = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; //Display emojis in mobile chat window NSData *data = [objchat.strchat dataUsingEncoding:NSUTF8StringEncoding]; NSString *valueEmoj = [[NSString alloc] initWithData:data encoding:NSNonLossyASCIIStringEncoding]; cell.txtchat.text=valueEmoj; 

Using the above code, I can store and display emojis in the chat window, but if the recipient user closed the application, then in the push message I can not display the emojis symbol in the push message.

thanks

enter image description here

+8
php ios iphone notifications apple-push-notifications
source share
2 answers

you do not have to deal with the html extension. As you say, the code for a smiling face is \u263A . In PHP, you can imagine that in UTF8 encoding as "\xE2\x98\xBA"

The lightning bolt (actually the "high voltage sign") is \u26A1 or "\xE2\x9A\xA1" in UTF-8.

Both of these characters are present in some non-emoji fonts like regular Unicode characters. You can see:

 <?php header('Content-type: text/html; charset=utf-8'); echo "\xE2\x9A\xA1"; echo "\xE2\x98\xBA"; 

I do not know where you got ; from, but it will be \ue13d , which is in the empty private use of Unicode, and not in Emoji in the Unicode standard. Check it here. Maybe it's from another Japanese mobile standard, but for iOS you should use Unicode.

You can get my above encodings from this table or use Emoji search tool .

As for Apple, click. This note says that you can send emoji as UTF-8 encoded strings, so it seems like a json object like {"alert":"\u26A1SHOCKER\u26A1"} will work.

+4
source share

for googlers. json_encode () adds double \

 $message = "\ue04a"; $body['aps'] = array( 'alert' => $message, 'sound' => 'default', 'type' => $type, 'param' => $param ); $payload = json_encode($body); $payload = str_replace("\", "\\", $payload); 
+1
source share

All Articles