苹果推送通知可以发送比警报和声音更多的参数吗? [英] Can apple push notifications send more parameters than alert and sound?

查看:109
本文介绍了苹果推送通知可以发送比警报和声音更多的参数吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将多个元数据与推送通知相关联。

I have several pieces of metadata that I need to associate with a push notification.

例如用户号,消息ID。

For example user no, message id.

我可以发送比苹果支持的更多参数:

Can I send more parameters than what apple supports:

 {aps =     {
    alert = joetheman;
    sound = default;
};}

这可能吗?

推荐答案

是的。在推送通知编程指南部分通知有效负载它声明

Yes. In the Push Notification Programming Guide section The Notification Payload it states


提供商可以指定Apple以外的自定义有效负载值保留aps命名空间。自定义值必须使用JSON结构化和原始类型:字典(对象),数组,字符串,数字和布尔值。您不应将客户信息包含为自定义有效负载数据。相反,将其用于设置上下文(用于用户界面)或内部指标等目的。例如,自定义有效负载值可以是由即时消息客户端应用程序使用的对话标识符,或者是标识提供者何时发送通知的时间戳。与警报消息关联的任何操作都不应具有破坏性 - 例如,删除设备上的数据。

Providers can specify custom payload values outside the Apple-reserved aps namespace. Custom values must use the JSON structured and primitive types: dictionary (object), array, string, number, and Boolean. You should not include customer information as custom payload data. Instead, use it for such purposes as setting context (for the user interface) or internal metrics. For example, a custom payload value might be a conversation identifier for use by an instant-message client application or a timestamp identifying when the provider sent the notification. Any action associated with an alert message should not be destructive—for example, deleting data on the device.

因此您的有效负载可能看起来像

So your payload might look like

{
    "aps": {
        "alert": "joetheman",
        "sound": "default"
    },
    "message": "Some custom message for your app",
    "id": 1234
}

在同一页面上还有许多证明这一点的例子。

Further down on that same page are a number of examples that demonstrate this.

这篇关于苹果推送通知可以发送比警报和声音更多的参数吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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