What is the maximum number of characters that can be displayed in Android and iOS push notification?
Asked Answered
A

6

29

What is the maximum number of characters that can be displayed in push notification in Android without the text being truncated?

The documentation for iPhone states that the notification payload has to be under 256 bytes in total, but I was unable to find something similar for Android.

Adjoint answered 28/2, 2012 at 17:58 Comment(2)
Here the same question has been answered: #6308248Bister
Andrea, this questions is specific to Android, but that question pertains only to iOS.Manella
V
36

Android

The message size limit in Firebase Cloud Messaging (FCM) is 4 kbytes. https://firebase.google.com/docs/cloud-messaging/concept-options#notification-messages-with-optional-data-payload

https://firebase.google.com/docs/cloud-messaging/server#choose

The message size limit in GCM is 4 kbytes. (DEPRECATED) https://developer.android.com/google/gcm/server.html#params

The message size limit in C2DM is 1024 bytes. (DEPRECATED) https://developers.google.com/android/c2dm/#limitations


iOS

For regular remote notifications, the maximum size is 4KB (4096 bytes)

https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CreatingtheNotificationPayload.html

Since the introduction of iOS 8 has changed to 2 kbytes!

https://forums.aws.amazon.com/ann.jspa?annID=2626

With iOS 8, Apple introduced new features that enable some rich new use cases for mobile push notifications — interactive push notifications, third party widgets, and larger (2 KB) payloads. Today, we are pleased to announce support for the new mobile push capabilities announced with iOS 8. We are publishing a new iOS 8 Sample App that demonstrates how these new features can be implemented with SNS, and have also implemented support for larger 2KB payloads.

in iOS the size limit is 256 bytes

Vouvray answered 22/9, 2014 at 23:19 Comment(2)
C2DM is deprecated, it's, quote "a limit on the total size of the message (4kb)", please see developer.android.com/google/gcm/server.html#params for detailsLeatherworker
yep, thanks for the info, i have updated the answer.Vouvray
M
14

As kabuko said there are a lot of variables. But I did testing on a Galaxy S5 and a Nexus 5, with Android 4.4, and got similar results. If you are looking for ballpark figures I got

Title: 16 chars Text: 27 chars Ticker: 300+ chars (I stopped at 300 characters)

NotificationCompat.Builder builder = new     NotificationCompat.Builder(application.getApplicationContext());

Notification n = builder
    .setContentTitle("XXXXXXXXXXWWWWWWWWWW")
    .setContentText("XXXXXXXXXXWWWWWWWWWWXXXXXXXXXX")
    .setTicker("XXXXXXXXXXWWWWWWWWWWXXXXXXXXXXWWWWWWWWWWXXXXXXXXXWWWWWWWWWW...") // cut short for brevity
    .setSmallIcon(R.drawable.ic_launcher)
    .build();
Miliary answered 5/1, 2015 at 22:40 Comment(0)
M
7

C2DM messages are limited in size to 1024 bytes and are intended to inform the device about new data not to transfer it.

Links:

http://www.vogella.de/articles/AndroidCloudToDeviceMessaging/article.html http://code.google.com/android/c2dm/

Moll answered 28/2, 2012 at 18:7 Comment(2)
Thank you for the answer, but I need to know how many charecters cab be 'displayed' on the screen when the push notification is pulled down and not how many bytes can be transferred..Adjoint
you can receive max 1024 chars and after receiving it is upto you how you want to show to the user.Moll
D
6

Don't assume that just because something works one way in iOS, that's how it works in Android. As Vineet alludes to, in Android's C2DM only deals with data. It does not deal with UI. Adding a notification in the notifications tray is a common thing to do with that push notification, but it's not directly related. As noted in other answers, the message size limit is 1024 bytes.

If you're concerned about how many characters can fit in a notification in the tray however, there is technically no hard limit. For one, Android does not use fixed width fonts (by default) in the tray. A string of 10 characters like "llllllllll" will be a different width than a string of 10 characters like "WWWWWWWWWW". Additionally, you can do custom views in notifications, meaning you can change the font size which would change the number of characters that you can fit.

Dissemblance answered 28/2, 2012 at 19:1 Comment(0)
Q
2

GCM (Google Cloud Messaging)- 4kb

ref : https://developers.google.com/cloud-messaging/server#choose

FCM (firebase cloud messaging)- 4kb

ref: https://firebase.google.com/docs/cloud-messaging/server#choose

Quechua answered 23/9, 2016 at 12:49 Comment(0)
D
1

The message size limit is 1024 bytes.

http://code.google.com/android/c2dm/index.html#limitations

Deboradeborah answered 28/2, 2012 at 18:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.