Apple 推送通知中的表情符号支持 [英] Emojis support in Apple push notification

查看:74
本文介绍了Apple 推送通知中的表情符号支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发名为INTERSTIZIO"的 iPhone 应用程序.在这个应用程序中,我实现了用户之间聊天等功能.在此用户可以发送带有表情符号的文本、位置和文本.如果应用程序在接收端未处于打开模式然后从后端推送生成并显示给接收器.我可以在推送中显示消息,如用户名:你好..."但我也想在推送消息中显示表情符号,如用户名:Hay :)",以便任何人知道如何使用苹果的表情符号代码(例如微笑苹果代码是 \u263a)来实现这种类型的推送消息?

我遵循了此链接中给出的解决方案: 可能来自其他一些日本移动运营商标准,但对于 iOS,您应该使用 Unicode.

你可以从这张表获取我上面的编码或者使用这个表情符号搜索工具.

至于苹果推送.此注释 说您可以将表情符号作为 UTF-8 编码字符串发送,所以像 {"alert":"\u26A1SHOCKER\u26A1"} 这样的 json 对象听起来会起作用.

I am working on iPhone app named "INTERSTIZIO".In this I have implemented functionality like chat between users.In this user can send text,location and text with emojis symbol.If the app is not in open mode at receiver end then from backend push is generated and display to receiver.I am able to display message in push like "UserName : Hello..." but I also want to display emojis symbol, like "UserName : Hay :)" in push message so anyone have idea regarding how I can achieve this type of push message using emojis code(like for smile apple code is \u263a) of apple?

I have followed the solution given in this link : http://code.iamcal.com/php/emoji/ But it returns the same code that I have passed in function.Its working fine on web pages but not in push message.

Here I am attaching one screen shot of the push how it looks at my end.In it you can see that I have displayed smiley and lighting symbol but its displayed using HTML supported code like below code of PHP script:

$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 have displayed inbuilt emojis keyboard from apple and using below code I am able to get 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 above code I am able to store and display emojis in chat window but if receiver user have closed app then in push message I am not able to display emojis symbol in push message.

Thanks

解决方案

you shouldn't need to mess about with html decoding. As you say the code point for smiling face is \u263A. In PHP you can represent that in a UTF8-encoded string as "\xE2\x98\xBA"

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

Both these characters are present in some non-emoji fonts as regular Unicode symbols. You can see with:

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

I don't know where you got &#57661; from, but that would be \ue13d which is in an empty private use Unicode range, and not an Emoji within the Unicode standard Check it here Possibly it's from some other Japanese mobile carrier standard, but for iOS you should use Unicode.

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

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

这篇关于Apple 推送通知中的表情符号支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆