[英]Sending Emoji in Push Notifications via PHP on iOS
我想發送一些帶有推送通知的表情符號圖標,但不知道我是如何做到的。
有沒有人用 PHP 成功實現了這個? 例如,我只想在推送消息前加上笑臉。
我的問題純粹是關於表情符號,我有一個成功的 APNS 腳本。
感謝您的任何指導。
使用html_entity_decode()
有一個快速的'n臟方法:
例子:
$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}!";
基本上,您只需使用您想要使用的表情符號圖標的十進制(不是十六進制)代碼創建一個 HTML 實體,html_entity_decode html_entity_decode()
會將其轉換為您可以在字符串中使用的正確 Unicode 字符。 在前面提到的http://code.iamcal.com/php/emoji/URL處有一個 Unicode 代碼點的目錄。
此方法適用於您無法在文本編輯器中輸入的任何字符,無論是否是表情符號。
這是一個很好的資源: http://code.iamcal.com/php/emoji/
將其作為附加屬性發送到 APNS JSON 有效負載
{"aps":{"alert":"Your Message","sound":"push1.wav"},"emoji":"emoji_name"}
但你不能在 UIAlertView 中顯示它們,你只能在應用程序中顯示它們
請注意,JSON 有效負載必須對 rfc4627 有效,因此您只能使用 Unicode 字符
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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.