Tal
Tal

Reputation: 7997

Why is my GCM notification truncated? (Cordova PushPlugin)

I'm sending a very simply GCM push notification over HTTP. On my android it displays the first 32 characters, following by 3 dots. Messages from other apps appear just fine, all wrapped nicely.

The app side is an Ionic application (Cordova) using PushPlugin as the client notification code.

example, the following code results in the message: this is not such a long message to be trun...

POST: https://android.googleapis.com/gcm/send    
{       
  "registration_ids":["secret"],
  "data": {
        "message" : "this is not such a long message to be truncated"
  }
}

Anyone knows this plugin and can help configuring it to display multiline notifications?

Upvotes: 1

Views: 1080

Answers (3)

Ajoy
Ajoy

Reputation: 1848

As ShibbyUK answered, use BigTextStyle:

  • There is a pull request for PushPlugin that does just this.

  • Or you could modify the plugin yourself, by making these changes:

    if (extras.getString("bigview") != null) {
        boolean bigview = Boolean.parseBoolean(extras.getString("bigview"));
        if (bigview) {
            mBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(message));
        }
    }
    

Upvotes: 2

user5229505
user5229505

Reputation:

The code you provided is only the server side implementation of the GCM. For the client side (e.g. Android) it seems you used the sample Google provided on its docs.

If you want to handle your message, you have to modify (or implement) the client side too. There you can choose how to display it on your devices in the Android (or iOS).

Upvotes: 1

ShibbyUK
ShibbyUK

Reputation: 1521

You can set the style to "BigTextStyle" with setStyle when you build the notification e.g.

myBuilder.setStyle(new NotificationCompat.BigTextStyle()
        .bigText("this is not such a long message to be truncated"))

Upvotes: 1

Related Questions