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.

Jorgesys
  • 124,308
  • 23
  • 334
  • 268
Ahmed Faisal
  • 4,397
  • 12
  • 45
  • 74
  • Here the same question has been answered: http://stackoverflow.com/questions/6307748/what-is-the-maximum-length-of-a-push-notification-alert-text – Andrea Avesani Nov 26 '15 at 14:46
  • 2
    Andrea, this questions is specific to Android, but that question pertains only to iOS. – Jade Mar 14 '16 at 16:54

6 Answers6

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

Tomonso Ejang
  • 1,336
  • 3
  • 15
  • 27
Jorgesys
  • 124,308
  • 23
  • 334
  • 268
  • 1
    C2DM is deprecated, it's, quote "a limit on the total size of the message (4kb)", please see https://developer.android.com/google/gcm/server.html#params for details – Mia Oct 21 '14 at 02:40
  • 1
    yep, thanks for the info, i have updated the answer. – Jorgesys Apr 04 '17 at 23:07
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();
Moemars
  • 4,692
  • 3
  • 27
  • 30
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/

Vineet Shukla
  • 23,865
  • 10
  • 55
  • 63
  • 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.. – Ahmed Faisal Feb 28 '12 at 18:16
  • 3
    you can receive max 1024 chars and after receiving it is upto you how you want to show to the user. – Vineet Shukla Feb 28 '12 at 18:36
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.

kabuko
  • 36,028
  • 10
  • 80
  • 93
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

Bikesh M
  • 8,163
  • 6
  • 40
  • 52
1

The message size limit is 1024 bytes.

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

NyanLH
  • 480
  • 1
  • 6
  • 17