APN (Apple Push Notification) payload size limit
Asked Answered
T

5

44

In official documentation you 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.

However in WWDC 14 we can see this screenshot:

enter image description here

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?

Tara answered 7/10, 2014 at 10:17 Comment(5)
From my own testing, it fits about 3-4 lines of text that you see on the alert popup screen. Each line has about a few words. I tend to think it resembles the amount you can write inside a Tweet, maybe a little bit lesser. I don't know about refusing the notification but I do know that if I put more text than 3 - 4 lines, they get truncated and not shown.Caboose
It looks like Apple haven't updated their APNS docs yet. I couldn't find any official Apple doc that mentions the increase in payload size.Korte
256 bytes for iOS7- and 2KB for iOS8+. Fore HTTP/2 its 4KB. Read more : jeenalinfotech.com/blogs/ios/…Mellisa
@Caboose notifications can also be used to send data that is not shown to the user; hence the interest in knowing how large the payload can be.Jacksmelt
I'm using VOIP and alert object size still truncate nearly around ~1KB. How max limit 5KB can be used in case of VOIP. Any suggestion ?Photomicrograph
T
76

Apple has already updated the documentation. The 2KB for the maximum payload size is just for devices running iOS 8. The official doc says:

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.)


As per the updated Apple docs the size is 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

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)

Tomfool answered 18/11, 2014 at 12:18 Comment(8)
I want to mention that in contrast to the docs the 256 byte limit does not seem to apply to iOS 7. People tested and confirmed that their iOS 7 devices happily receive messages > 256 bytes. github.com/djacobs/PyAPNs/pull/79#issuecomment-51021572Os
So Is it 2000 bytes or 2048 bytes ?Integer
@Integer clearly says 2 kilobytes, so your answer is 2000 bytes. A kibibit KiB (en.wikipedia.org/wiki/Kibibit) is 1024 bytes. But anyway, we all know Apple messes with these definitions (they probably use kilobytes as 1024 in software terms, but on device storage size they use 1000).Butts
Updated documentation: developer.apple.com/library/ios/documentation/…Denaedenarius
@Integer The correct answer is 2048 bytes, not 2000 bytes, per the docs.Boigie
This explanation is now a bit dated; the documentation has moved and the new answer is either 2048 bytes via the binary interface or 4096 bytes via the HTTP/2 API.Boigie
2KB means 2048 bytesCozenage
@Cozenage - Actually, the point that was originally made by Alejandro, is that, by international standard (see his wiki link), 2KiB means 2048 bytes, and 2KB means 2000 bytes. However, in practice, KB has been used so commonly, for so long in computer software, to mean 1024, that it is not safe to assume either way. I myself don't abide by that standard, hard to break a habit of many decades, so I can't complain ;)Jacksmelt
S
32

For iOS 9 there are some changes:

Introduction of HTTP/2
Payload increased to 4KB

4 KB limit apply to all versions of iOS and 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)

Check this video link for more details regarding the features of HTTP/2
https://developer.apple.com/videos/play/wwdc2015-720/

Smallish answered 30/10, 2015 at 16:36 Comment(3)
this is not true yet, they will add those things in 2016, as far as I know, there is no dateDante
http/2 apns is officially supported. developer.apple.com/news/?id=12172015bFoldaway
Hi, I'm using VOIP but it still truncate alter object size to 512 byte only. How that make sense when Apple Document say it's increase to 5KB for VOIP. Any suggestion ?Photomicrograph
F
3

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.

Edit: Urban Airship also updated their backend for 2KB as well.

Farmstead answered 7/10, 2014 at 10:32 Comment(0)
F
2
  • 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)

Apple Docs : https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CreatingtheNotificationPayload.html#//apple_ref/doc/uid/TP40008194-CH10-SW1

Freeswimming answered 24/2, 2017 at 5:13 Comment(0)
B
1

Per the most recent official documentation, the payload limit is 4096 bytes or 2048 bytes for regular notifications, and 5120 bytes for VoIP notifications:

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).

Prior to iOS 8, the limit was 256 bytes.

Boigie answered 16/6, 2016 at 16:15 Comment(2)
Good information but FYI the link is not available.Milligan
@ipr Thanks, Apple has a regular habit of moving their documentation. Updated and included new most recent information.Boigie

© 2022 - 2024 — McMap. All rights reserved.