ios APN(Apple 推送通知)有效负载大小限制
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26233730/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
APN (Apple Push Notification) payload size limit
提问by Jakub
In official documentationyou can find the info:
在官方文档中,您可以找到以下信息:
Each push notification includes a payload. The payload contains information about how the system should alert the user as well as any custom data you provide. The maximum size allowed for a notification payload is 256 bytes; Apple Push Notification Service refuses any notification that exceeds this limit.
每个推送通知都包含一个有效负载。有效负载包含有关系统应如何提醒用户以及您提供的任何自定义数据的信息。通知负载允许的最大大小为256 字节;Apple 推送通知服务拒绝任何超过此限制的通知。
However in WWDC 14 we can see this screenshot:
但是在 WWDC 14 中我们可以看到这个截图:
I wonder if there is any official Apple statement about the size limit of push notification. I tested it and larger that 256 bytes works, but documentation said it shouldn't. Can someone confirm or deny the size of remote notifications?
不知道苹果官方有没有关于推送通知大小限制的声明。我测试了它并且更大的 256 字节有效,但文档说它不应该。有人可以确认或否认远程通知的大小吗?
回答by Xavier Maro?as
Apple has already updated the documentation. The 2KB for the maximum payload size is just for devices running iOS 8. The official docsays:
Apple 已经更新了文档。最大负载大小的 2KB 仅适用于运行 iOS 8 的设备。官方文档说:
In iOS 8 and later, the maximum size allowed for a notification payload is 2 kilobytes; Apple Push Notification service refuses any notification that exceeds this limit. (Prior to iOS 8 and in OS X, the maximum payload size is 256 bytes.)
在 iOS 8 及更高版本中,通知负载允许的最大大小为 2 KB;Apple 推送通知服务拒绝任何超过此限制的通知。(在 iOS 8 和 OS X 之前,最大有效负载大小为 256 字节。)
As per the updated Apple docsthe size is 4KB.
根据更新的Apple 文档,大小为 4KB。
- For regular remote notifications, the maximum size is 4KB (4096 bytes)
- For Voice over Internet Protocol (VoIP) notifications, the maximum size is 5KB (5120 bytes) NOTE
- 对于常规远程通知,最大大小为 4KB(4096 字节)
- 对于互联网协议语音 (VoIP) 通知,最大大小为 5KB(5120 字节) 注意
If you are using the legacy APNs binary interface to send notifications instead of an HTTP/2 request, the maximum payload size is 2KB (2048 bytes)
如果您使用旧版 APNs 二进制接口发送通知而不是 HTTP/2 请求,则最大负载大小为 2KB(2048 字节)
回答by Rajan Maheshwari
For iOS 9 there are some changes:
对于 iOS 9,有一些变化:
Introduction of HTTP/2
Payload increased to 4KB
引入 HTTP/2
Payload 增加到 4KB
4 KB limit apply to all versions of iOS and OS 10
4 KB 限制适用于所有版本的 iOS 和 OS 10
Check this official link
检查这个官方链接
For regular remote notifications, the maximum size is 4KB(4096 bytes)
For Voice over Internet Protocol (VoIP) notifications, the maximum size is 5KB(5120 bytes)
If you are using the legacy APNs binary interface to send notifications instead of an HTTP/2 request, the maximum payload size is 2KB(2048 bytes)
对于常规远程通知,最大大小为4KB(4096 字节)
对于互联网协议语音 (VoIP) 通知,最大大小为5KB(5120 字节)
如果您使用旧版 APNs 二进制接口发送通知而不是 HTTP/2 请求,则最大负载大小为2KB(2048 字节)
Check this video link for more details regarding the features of HTTP/2
https://developer.apple.com/videos/play/wwdc2015-720/
查看此视频链接,了解有关 HTTP/2 功能的更多详细信息
https://developer.apple.com/videos/play/wwdc2015-720/
回答by Nicholas Smith
According to the testing from the node-apn project the size was expanded from 256 to 2KB over the beta period, I think it's likely Apple hasn't updated their documentation to reflect this change. The discussion on the node-apn project.
根据 node-apn 项目的测试,在 beta 期间,大小从 256 扩展到 2KB,我认为 Apple 可能没有更新他们的文档来反映这一变化。关于 node-apn 项目的讨论。
Edit: Urban Airship also updated their backend for 2KB as well.
回答by Anand Kore
- For regular remote notifications, the maximum size is 4KB (4096 bytes)
- For Voice over Internet Protocol (VoIP)notifications, the maximum size is 5KB (5120 bytes)
- 对于常规远程通知,最大大小为4KB(4096 字节)
- 对于互联网协议语音 (VoIP)通知,最大大小为5KB(5120 字节)
NOTE
笔记
If you are using the legacy APNs binary interface to send notifications instead of an HTTP/2 request, the maximum payload size is 2KB (2048 bytes)
如果您使用旧版 APNs 二进制接口发送通知而不是 HTTP/2 请求,则最大负载大小为 2KB(2048 字节)
苹果文档:https: //developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CreatingtheNotificationPayload.html#//apple_ref/doc/uid/TP40008194-CH10-SW1
回答by Brad Koch
Per the most recent official documentation, the payload limit is 4096 bytes or 2048 bytes for regular notifications, and 5120 bytes for VoIP notifications:
根据最新的官方文档,常规通知的有效负载限制为 4096 字节或 2048 字节,VoIP 通知为 5120 字节:
The maximum size of the payload depends on the notification you are sending:
- For regular remote notifications, the maximum size is 4KB (4096 bytes)
- For Voice over Internet Protocol (VoIP) notifications, the maximum size is 5KB (5120 bytes)
Note: If you are using the legacy APNs binary interface to send notifications instead of an HTTP/2 request, the maximum payload size is 2KB (2048 bytes).
负载的最大大小取决于您发送的通知:
- 对于常规远程通知,最大大小为 4KB(4096 字节)
- 对于互联网协议语音 (VoIP) 通知,最大大小为 5KB(5120 字节)
注意:如果您使用旧版 APNs 二进制接口发送通知而不是 HTTP/2 请求,则最大负载大小为 2KB(2048 字节)。
Prior to iOS 8, the limit was 256 bytes.
在 iOS 8 之前,限制为 256 字节。