简体   繁体   English

如何使用pushd设置iOS推送通知的标题?

[英]How to set title for iOS push notification using pushd?

In Apple iOS documentation it is mentioned that: 在Apple iOS文档中提到:

alert string/dictionary 警报字符串/字典

If this property is included, the system displays a standard alert or a banner, based on the user's setting. 如果包括此属性,则系统将根据用户的设置显示标准警报或横幅。 You can specify a string or a dictionary as the value of alert. 您可以将字符串或字典指定为alert的值。 If you specify a string, it becomes the message text of an alert with two buttons: Close and View. 如果指定字符串,它将成为带有两个按钮的警报消息文本:“关闭”和“查看”。 If the user taps View, the app launches. 如果用户点击查看,则该应用程序将启动。 If you specify a dictionary, refer to Table 5-2 for descriptions of the keys of this dictionary. 如果指定词典,请参阅表5-2了解此词典的键。

title string 标题字符串

A short string describing the purpose of the notification. 描述通知目的的简短字符串。 Apple Watch displays this string as part of the notification interface. Apple Watch将此字符串显示为通知界面的一部分。 This string is displayed only briefly and should be crafted so that it can be understood quickly. 该字符串仅显示简短,应精心制作,以便快速理解。 This key was added in iOS 8.2. 此密钥是在iOS 8.2中添加的。

body string 身体

The text of the alert message. 警报消息的文本。

Now I want to set title for the push notification to be shown on iOS, I have sent the below payload: 现在,我想为要在iOS上显示的推送通知设置标题,我已发送以下有效负载:

{'data.project': {'ack': 0,
              'c': {'id': 'SOME DATA'},
              'ca': 1,
              't': 'e/user',
              'v': '1',
              'vm': 2},
 'msg': 'My message',
 'title': 'My custom title'}

The push is sent but no title is set on the mobile device. 已发送推送,但在移动设备上未设置标题。 Does pushd support it? pushd支持吗? What should I do? 我该怎么办?

Use this JSON Payload for sending push notification from backend. 使用此JSON有效负载从后端发送推送通知。 Hope this will help you. 希望这会帮助你。 Here, "title" is the title of push notification and "body" is the text of alert message. 在这里, “标题”是推送通知的标题, “正文”是警报消息的文本。

{
     "registration_ids" : ["put_id_here"],
    "notification" : {
        "content_available" : true,
        "body" : "this is body",
        "title" : "this is title",
        "sound" : "default",
        "badge" : 1
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM