问题描述
内置的消息应用在推送通知中使消息发送者的名字粗体.
The built-in Messages app makes message-senders' names in push notifications bold.
是否可以为我的应用执行此操作?这样的有效载荷会是什么样子?
Is it possible to do this for my app? What would such a payload look like?
如果相关,我正在测试使用 Mac 应用程序 APN Tester 向我的 iPhone 发送推送,使用这种类型的有效负载 {"aps": {"alert": "hey bob", "badge": 2}}
.
If it's relevant, I'm testing using the Mac app APN Tester to send a push to my iPhone, with this type of payload {"aps": {"alert": "hey bob", "badge": 2}}
.
(我试过星号 *text*
和 HTML 标签 <b>text</b>
但他们什么也没做.我似乎不能找到有关它的文档.)
(I tried asterisks *text*
and HTML tags <b>text</b>
but they don't do anything. I can't seem to find documentation on it, either.)
推荐答案
iOS 推送通知中没有富文本功能.
There is no rich text functionality in iOS Push Notifications.
iOS 8.2 plus 的另一种选择可能是使用标题"来显示发件人的姓名,并将新消息放在正文中.例如,尝试这样的有效负载:
An alternative for iOS 8.2 plus may be to use the 'title' to display the sender's name, and place the new message in the body. For example, try a payload such as this:
{
"aps": {
"alert": {
"title": "Jim",
"body": "Hey bob"
},
"badge": 2
}
}
这篇关于iOS 推送通知中的粗体(或其他格式)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!