mootymoots
mootymoots

Reputation: 4575

Sending Emoji in Push Notifications via PHP on iOS

I'd like to send some emoji icons with push notifications, but have no idea how I do that.

Has anyone successfully implemented this with PHP? I just want to prepend my push message with a smiley face for example.

My question is purely about emoji, I have a successful APNS script.

Thanks for any guidance.

Upvotes: 3

Views: 10662

Answers (3)

Nick Baicoianu
Nick Baicoianu

Reputation: 2295

There's a quick 'n dirty way to do this using html_entity_decode():

Example:

$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}!"; 

Basically, you just create an HTML Entity with the decimal (not hex) code of the Emoji icon you'd like to use, and html_entity_decode() will convert it to the correct Unicode character that you can use in a string. There's a catalog of Unicode code points at the previously-mentioned http://code.iamcal.com/php/emoji/ URL.

This method should work for any character you can't type into your text editor, emoji or not.

Upvotes: 13

JK.
JK.

Reputation: 5136

This is a good resource for that: http://code.iamcal.com/php/emoji/

Upvotes: 2

Marek Sebera
Marek Sebera

Reputation: 40661

Send it as additional attribute to APNS JSON payload

{"aps":{"alert":"Your Message","sound":"push1.wav"},"emoji":"emoji_name"}

but you can't display them inside of UIAlertView, you can only in application

APNS JSON PAYLOAD - more arguments

Note that JSON payload must be valid by rfc4627 so you can use only Unicode characters

http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ApplePushService/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW1
http://www.ietf.org/rfc/rfc4627.txt

Upvotes: 0

Related Questions