表情符号不显示在推送通知中

Emoji does not display in push Notification

我在我的应用程序中实现了推送通知的功能。这会在推送通知中显示文本消息,但不会显示表情符号。它显示像 '\u270c' 这样的 ascii 代码而不是表情符号。

谁能告诉我如何在推送通知中显示表情符号

您需要更改您的 unicode 格式才能在推送通知和本地通知中显示表情符号。

按如下方式更新您的 unicode:

"\u{270c}"

希望对您有所帮助。

参考:https://docs.swift.org/swift-book/LanguageGuide/StringsAndCharacters.html

要在推送通知中显示表情符号,请使用 JSON 在服务器端解码。它为我解决了这个问题 在 APNS 推送通知代码的服务器端执行此操作,将像 charm

$payload['aps'] = array('alert' => json_decode('"'.$pushMsg['message'].'"'), 'badge' => 0, 'sound' => 'default', 'passcode' => $pushMsg);