30

I'm brand new to IOS push notifications. I have been reading about them and can't seem to find this information anywhere. I have read that the size limit on a push notification is 256 Bytes. Does this size limit include things such as the device token that have to be sent and other overhead information about the notification. If so what is the actual size I have avaliable for my content.

Also what format are they using to interpret the text that I send? Is the conversion 1 character = 1 byte or is it more than that. Really I want to know how many characters can I send in a push notifications.

Thanks for any help in understanding the limitations of push notification payloads.

Andrey Zverev
  • 4,371
  • 1
  • 26
  • 34
jcmitch
  • 1,896
  • 9
  • 24
  • 33

3 Answers3

49

Each push notification carries with it a payload. The payload specifies how users are to be alerted to the data waiting to be downloaded to the client application. The maximum size allowed for a notification payload is 256 bytes; Apple Push Notification Service refuses any notification that exceeds this limit.

For each notification, providers must compose a JSON dictionary object that strictly adheres to RFC 4627. This dictionary must contain another dictionary identified by the key aps. The aps dictionary contains one or more properties that specify the following actions:

  • An alert message to display to the user
  • A number to badge the application icon with
  • A sound to play

- Local and Push Notifications Programming Guide

So, answering your question,

Does this size limit include things such as the device token that have to be sent and other overhead information about the notification.

Yes, this size limit includes device token and other overhead information.

Is the conversion 1 character = 1 byte or is it more than that.

This is true if you're using only Latin letters in your notification.

Andrey Zverev
  • 4,371
  • 1
  • 26
  • 34
  • Okay since that does include the overhead do you know how much space I would have remaining after the overhead is taken into account? (Total space - Overhead = ? # of remaining characters) Thanks. – jcmitch Feb 07 '12 at 20:52
  • 13
    considering the payload is minimal and only contains the alert information, you have about 236 characters for your text. But notice that push `UIAlertView` display limit is 107 characters. After that your message gets truncated and you will get a "..." at the end of the displayed message. – Andrey Zverev Feb 07 '12 at 21:06
  • Okay thanks. The UIAlertView shouldn't be a problem. Just need to attach data to be used later in the payload. – jcmitch Feb 07 '12 at 21:09
  • 2
    @AndreyZ. - my tokens are 64 chars - how can there be 236 chars remaining if 256 doesn't include the token? :-S – ostergaard Nov 01 '13 at 07:03
  • 1
    Given that 'include' can be understood both ways in all of the above, to be clear: the device ID is *not* taken out of your 256 character budget. – tooluser Jan 18 '14 at 19:02
  • It's not valid any more when you start localize push notifications, payload may be short while final message may be much longer. The question is about displaying message it's not strictly related to payload maximum length. – Marcin Feb 17 '14 at 11:51
  • 2
    iOS 8 has a 2KB limit, does that mean pre-iOS 8 devices can also receive push messages greater than 256 chars? – Ragunath Jawahar Nov 04 '14 at 05:42
  • 2
    @RagunathJawahar, I've been testing and I can receive 2KB on iOS 7 devices. – jcesarmobile Dec 23 '14 at 14:06
  • @jcesarmobile Thank you for mentioning that :) – Ragunath Jawahar Dec 24 '14 at 12:20
5

The above is all fairly unclear, because 'include' can mean "it is already included" or "you must include it". To be very clear, the device ID is 'metadata', not part of the payload, and does not come out of your 256 character budget. The other APS overhead (standard payload dictionary), though, is.

Source: the above documentation plus experimentation to verify.

tooluser
  • 1,418
  • 14
  • 21
3

In my APNS test in the production environment, up to 33 Chinese characters and 2 custom properties of 13 bytes could be sent successfully.

{

    "aps": {
        "alert": "一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三",
        "badge": 12,
    }
    "t": 123,
    "v": "1234567890"
}

The above payload length was 158 bytes if saved as file, not counting the space characters. Each Chinese character was counted as 3 bytes (I confirmed that by removing all of them to see the size change).

As official document mentioned, the 256-bytes limitation does not include the device token , but I believe there are other characters APNS are counted in, such as 'sound' and 'content-available' even if you do not use explicitly.

So be careful not to be 'too long', especially when using custom payloads. Be aware that APNS development environment does not limit the payload length. Your test pass while using development environment, but may fail in product. Do not take it as certain.

firebear
  • 754
  • 1
  • 8
  • 18