4

Im suffering from a problem in notification. Im doing my project in PHONEGAP. I want to show multiple lines in push notification in android. Now i am only getting single line notification. i cannot expand or do anything with that notification. im using a phonegap plugin.

com.phonegap.plugins.PushPlugin

Please help me to overcome this problem. Screen shot is given below.

Current Notification enter image description here

Expected Notification

Ali
  • 539
  • 4
  • 18
Dino
  • 806
  • 1
  • 8
  • 22
  • Hope this will help : http://stackoverflow.com/questions/7706818/how-can-i-send-an-apple-push-notification-with-multiple-lines-i-e-with-a-n-c – Abhishek Jun 25 '15 at 18:30

2 Answers2

4

This involves a custom layout in the native notification (remoteviews) , so it is needed to modify you favorite plugin

Android custom notification layout with RemoteViews

In case of this plugin: https://github.com/phonegap-build/PushPlugin

  1. Modify GCMIntentService.java, particulary NotificationCompat.Builder setContent with a the custom View. This custom view can be loaded from xml or instatiated by code: How to create a RelativeLayout programmatically with two buttons one on top of the other?

Example of a custom builder: Create custom notification, android

  1. Change the params for the plugin or parse payload message to separate lines
Community
  • 1
  • 1
Martín Alcubierre
  • 4,341
  • 1
  • 27
  • 27
  • how to modify ? can you be more specific ? Im using [this](https://github.com/phonegap-build/PushPlugin) plugin. I dont know about modifying the plugin. – Dino Sep 03 '14 at 08:54
  • Modify GCMIntentService.java, see answer – Martín Alcubierre Sep 03 '14 at 09:26
  • I want to show only the full message in notification. Now its only showing a single line of content and title(refer screenshot). can you please help me do the same with sample code if possible. Because i'm litle behind in android development. So i used phonegap. – Dino Sep 03 '14 at 10:20
  • And if you use .Net instead of Java ? – Tito Mar 13 '15 at 15:21
3

Path: \platforms\android\src\com\plugin\gcm

Filename: GCMIntentService.java

String message = extras.getString("message");
        if (message != null) {
            mBuilder.setContentText(message);
            mBuilder.setStyle(new NotificationCompat.BigTextStyle().bigText(message));//add this line
Sjoerd Pottuit
  • 2,307
  • 4
  • 20
  • 35
  • 1
    This solution has no effect on the style of the push notification. It still appears as one line on Android devices. Do you know what could be the problem? Do I have to clear cache somewhere or rest plugin? – Eyad May 10 '16 at 17:28