今天要說的還是推送,NND,這個推送這玩意,折騰死人
1、aps中是否只能有badge/alert/sound等參數?
答:不是,這個只是最基本的參數,可以有很多參數,但aps標記需要一定存在,其他參數可以自定義,比如:
- {
- "aps" : {
- },
- "acme2" : [ 5, 8 ]
- }
aps参数可以是空,但一定要有,上面这个可不是我杜撰的,这是官方的例子:http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ApplePushService/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW12
2、aps中的content-available是什么意思
答:这个是有特殊需要的时候才需要用,比如用来后台下载?说实话,我在官方没找到文档,反而在adobe找到一个小的介绍 :
第一个介绍:http://www.adobe.com/devnet/digitalpublishingsuite/articles/dps-push-notification.html
Table 3. Parameters for APNS messages
Property | value | description |
alert |
<string> |
The text message to display to the user. No localization arguments are supported. |
badge |
<number> |
If non-zero, it displays the number on the icon of the application. If zero, no number is displayed. |
content-available |
0 | 1 | Non-zero indicates a Newsstand push message. The receipt of this will wake the viewer to begin a background download. See Notes. |
sound |
"default" |
Only the default notification sound is supported. |
productID |
<string> |
Product. |
Notes about Newsstand background downloading
- Background downloads are limited to once every 24 hours, +/- 1 hour (or so). You can send as many alert messages you like, but only background downloading will be throttled.
- Background downloading will only happen over WiFi connections. If the user is on 3G and the push is received, the background download is lost.
- A valid subscription via Apple or direct entitlement (CDS, TCS, PCD, Dovetail, or other) must exist.
- Only the most recent folio will be background-downloaded. The user must be entitled to this content.
- Apple attempts a number of times to deliver the push payload. As such, the actual download may begin a significant amount of time after it was originally sent or scheduled.
用了content-available参数后,下一次接收一定是在24小时后。看上面的notes
还有一个介绍在这里:http://www.viggiosoft.com/blog/blog/2011/10/17/ios-newsstand-tutorial/,这篇博客很详细,还告诉你在APP中怎么设置,内容过长,我就不一一贴出来了。
它这么说:
The push notification message has the same syntax as standard push notifications with the only difference that the payload must contain the content-available key set to 1:
- {
- "aps":{
- "content-available":1,
- },
- "device_tokens": ["E9623F5CFDE92B40DA4AA90B97B70428BCD8FFCBA067BE17A6EF5102651E66E9"]
- }
There is one importation limitation related to the frequency of pushes: to limit the consumption of resources due to background downloading (which, by the way, we’ll happen only if the device is connected to a Wi-Fi network) Newsstand push notifications are coalesced and only one background download is permitted per day. For testing purposes you can remove this limit by setting an appropriate key in the user defaults (do this at startup in your App Delegate)