APNS JSON有效载荷 - 多个参数 [英] APNS JSON PAYLOAD - more arguments

查看:240
本文介绍了APNS JSON有效载荷 - 多个参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一些参数添加到一个JSON有效载荷APNS服务。我怎样才能做到这一点?
这是苹果的文档:<一href=\"http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ApplePushService/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW1\">http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ApplePushService/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW1

I need to add some arguments to a json payload for APNS service. How can i do this? this is the documentation of apple: http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ApplePushService/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW1

当我尝试发送带有密切和视图按钮,我需要增加两个论点,我的移动应用需求。
任何想法?

When i try to send a message with close and view buttons, i need to add two more arguments that my mobile application needs. Any idea?

推荐答案

不知道如果你得到了答案。但是,这是文档中提到什么

Not sure if you got the answer yet. But this is what the documentation mentions

提供商可以指定自定义负载
  苹果保留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.

因此​​,为了自定义值添加到您的有效载荷,只是他们加为你的有效载荷键 - 值对。事情是这样的。

So in order to add custom values to your payload, just add them as key-value pairs in your payload. Something like this

{
    "aps":{
        "alert":"Your Message",
        "sound":"push1.wav"
     },
     "custom_key1":"value1",
     "custom_key2":"value2"
}

下面 custom_key1 custom_key2 是你的自定义键和值1 值2 是他们的价值观。

Here custom_key1 and custom_key2 are your custom keys and value1 and value2 are their values.

这篇关于APNS JSON有效载荷 - 多个参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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