在 iOS 上通过 PHP 在推送通知中发送表情符号
我想发送一些带有推送通知的表情符号图标,但不知道该怎么做。
有人用 PHP 成功实现过这个吗?例如,我只想在推送消息前加上笑脸。
我的问题纯粹是关于表情符号,我有一个成功的 APNS 脚本。
感谢您的任何指导。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用
html_entity_decode()
有一种快速但肮脏的方法:示例:
基本上,您只需使用您想要使用的表情符号图标的十进制(而不是十六进制)代码创建一个 HTML 实体,并且
html_entity_decode()
会将其转换为可以在字符串中使用的正确 Unicode 字符。在前面提到的 http://code.iamcal.com/php/ 中有一个 Unicode 代码点目录表情符号/ 网址。此方法应该适用于您无法在文本编辑器中输入的任何字符,无论是否是表情符号。
There's a quick 'n dirty way to do this using
html_entity_decode()
:Example:
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.
这是一个很好的资源:http://code.iamcal.com/php/emoji/
This is a good resource for that: http://code.iamcal.com/php/emoji/
将其作为附加属性发送到 APNS JSON 负载
{"aps":{"alert":"Your Message","sound":"push1.wav"},"emoji":"emoji_name"}
但无法显示它们在 UIAlertView 内部,您只能在应用程序
APNS JSON 中PAYLOAD - 更多参数
请注意,JSON 负载必须通过 rfc4627 有效,因此您只能使用 Unicode 字符
http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ApplePushService/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW1< br>
http://www.ietf.org/rfc/rfc4627.txt
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