What is the maximum length of a Push Notification alert text?

后端 未结 11 1262
北海茫月
北海茫月 2020-11-30 16:28

What is the maximum length of the alert text of an iOS push notification?

The documentation states that the notification payload has to be under 256 bytes in total,

11条回答
  •  伪装坚强ぢ
    2020-11-30 17:04

    The real limits for the alert text are not documented anywhere. The only thing the documentation says is:

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

    This is what I could find doing some experiments.

    • Alerts: Prior to iOS 7, the alerts display limit was 107 characters. Bigger messages were truncated and you would get a "..." at the end of the displayed message. With iOS 7 the limit seems to be increased to 235 characters. If you go over 8 lines your message will also get truncated.
    • Banners: Banners get truncated around 62 characters or 2 lines.
    • Notification Center: The messages in the notification center get truncated around 110 characters or 4 lines.
    • Lock Screen: Same as a notification center.

    Just as a reminder here is a very good note from the official documentation:

    If necessary, iOS truncates your message so that it fits well in each notification delivery style; for best results, you shouldn’t truncate your message.

提交回复
热议问题