3

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.

mootymoots
  • 4,545
  • 9
  • 46
  • 74

3 Answers3

13

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.

Nick Baicoianu
  • 2,275
  • 20
  • 15
2

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

JK.
  • 5,126
  • 1
  • 27
  • 26
  • I seem to be missing a key implementation piece... where do I get the unicode codes from? – mootymoots Aug 10 '11 at 14:53
  • 1
    Look at the page linked in that answer! The column marked "Unified" has the codepoints which Apple uses, both on iOS and on OS X Lion. –  Aug 10 '11 at 18:44
0

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

Community
  • 1
  • 1
Marek Sebera
  • 39,650
  • 37
  • 158
  • 244
  • I've seen them in UIAlertViews though, can I not send the UNICODE value of the emoji character name perhaps? – mootymoots Aug 10 '11 at 14:44