Loading example/server/pushGCM.rb +1 −1 Changes for example/server/pushGCM.rb: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -4,6 +4,6 @@ GCM.host = 'https://android.googleapis.com/gcm/send' GCM.format = :json GCM.key = "API_KEY_GOES_HERE" destination = ["REGISTRATION_ID_GOES_HERE"] data = {:message => "PhoneGap Build rocks!", :msgcnt => "1", :soundname => "beep.wav"} data = {:message => "PhoneGap Build rocks!", :msgcnt => "1", :soundname => "beep.wav", :group => 1, :stacking => "There %n% notifications",} GCM.send_notification( destination, data) src/android/com/adobe/phonegap/push/GCMIntentService.java +51 −1 Changes for src/android/com/adobe/phonegap/push/GCMIntentService.java: 51 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -26,13 +26,26 @@ import android.net.Uri; import android.os.Bundle; import android.support.v4.app.NotificationCompat; import android.util.Log; import android.text.Html; import com.google.android.gcm.GCMBaseIntentService; import java.util.ArrayList; @SuppressLint("NewApi") public class GCMIntentService extends GCMBaseIntentService { private static final String LOG_TAG = "PushPlugin_GCMIntentService"; private static ArrayList messageList = new ArrayList(); public void setNotification(String message){ if(message == ""){ messageList.clear(); }else{ messageList.add(message); } } public GCMIntentService() { super("GCMIntentService"); Loading Loading @@ -105,6 +118,7 @@ public class GCMIntentService extends GCMBaseIntentService { } catch (NumberFormatException e) {} } NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context) //.setDefaults(defaults) Loading @@ -114,6 +128,7 @@ public class GCMIntentService extends GCMBaseIntentService { .setContentIntent(contentIntent) .setAutoCancel(true); SharedPreferences prefs = context.getSharedPreferences("com.adobe.phonegap.push", Context.MODE_PRIVATE); String localIcon = prefs.getString("icon", null); String localIconColor = prefs.getString("iconColor", null); Loading Loading @@ -212,8 +227,43 @@ public class GCMIntentService extends GCMBaseIntentService { } String message = extras.getString("message"); int group = 0; try { group = Integer.parseInt(extras.getString("group")); if(group == 1){ setNotification(message); Integer sizeList = messageList.size(); if(sizeList > 1){ String sizeListMessage = sizeList.toString(); String stacking = sizeList+" more"; if(extras.getString("stacking") != null){ stacking = extras.getString("stacking"); stacking = stacking.replace("%n%", sizeListMessage); } NotificationCompat.InboxStyle notificationInbox = new NotificationCompat.InboxStyle() .setBigContentTitle(extras.getString("title")) .setSummaryText(stacking); for(Object noticationMensage : messageList){ notificationInbox.addLine(Html.fromHtml(noticationMensage.toString())); } mBuilder.setStyle(notificationInbox); mBuilder.setLargeIcon(null); } } } catch(NumberFormatException e) { Log.e(LOG_TAG, "Number format exception - Error parsing Group: " + e.getMessage()); } catch(Exception e) { Log.e(LOG_TAG, "Number format exception - Error parsing Group" + e.getMessage()); } if (message != null) { mBuilder.setContentText(message); mBuilder.setContentText(Html.fromHtml(message)); } else { mBuilder.setContentText("<missing message content>"); } Loading src/android/com/adobe/phonegap/push/PushHandlerActivity.java +2 −0 Changes for src/android/com/adobe/phonegap/push/PushHandlerActivity.java: 2 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -20,6 +20,8 @@ public class PushHandlerActivity extends Activity */ @Override public void onCreate(Bundle savedInstanceState) { GCMIntentService gcm = new GCMIntentService(); gcm.setNotification(""); super.onCreate(savedInstanceState); Log.v(LOG_TAG, "onCreate"); Loading Loading
example/server/pushGCM.rb +1 −1 Changes for example/server/pushGCM.rb: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -4,6 +4,6 @@ GCM.host = 'https://android.googleapis.com/gcm/send' GCM.format = :json GCM.key = "API_KEY_GOES_HERE" destination = ["REGISTRATION_ID_GOES_HERE"] data = {:message => "PhoneGap Build rocks!", :msgcnt => "1", :soundname => "beep.wav"} data = {:message => "PhoneGap Build rocks!", :msgcnt => "1", :soundname => "beep.wav", :group => 1, :stacking => "There %n% notifications",} GCM.send_notification( destination, data)
src/android/com/adobe/phonegap/push/GCMIntentService.java +51 −1 Changes for src/android/com/adobe/phonegap/push/GCMIntentService.java: 51 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -26,13 +26,26 @@ import android.net.Uri; import android.os.Bundle; import android.support.v4.app.NotificationCompat; import android.util.Log; import android.text.Html; import com.google.android.gcm.GCMBaseIntentService; import java.util.ArrayList; @SuppressLint("NewApi") public class GCMIntentService extends GCMBaseIntentService { private static final String LOG_TAG = "PushPlugin_GCMIntentService"; private static ArrayList messageList = new ArrayList(); public void setNotification(String message){ if(message == ""){ messageList.clear(); }else{ messageList.add(message); } } public GCMIntentService() { super("GCMIntentService"); Loading Loading @@ -105,6 +118,7 @@ public class GCMIntentService extends GCMBaseIntentService { } catch (NumberFormatException e) {} } NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context) //.setDefaults(defaults) Loading @@ -114,6 +128,7 @@ public class GCMIntentService extends GCMBaseIntentService { .setContentIntent(contentIntent) .setAutoCancel(true); SharedPreferences prefs = context.getSharedPreferences("com.adobe.phonegap.push", Context.MODE_PRIVATE); String localIcon = prefs.getString("icon", null); String localIconColor = prefs.getString("iconColor", null); Loading Loading @@ -212,8 +227,43 @@ public class GCMIntentService extends GCMBaseIntentService { } String message = extras.getString("message"); int group = 0; try { group = Integer.parseInt(extras.getString("group")); if(group == 1){ setNotification(message); Integer sizeList = messageList.size(); if(sizeList > 1){ String sizeListMessage = sizeList.toString(); String stacking = sizeList+" more"; if(extras.getString("stacking") != null){ stacking = extras.getString("stacking"); stacking = stacking.replace("%n%", sizeListMessage); } NotificationCompat.InboxStyle notificationInbox = new NotificationCompat.InboxStyle() .setBigContentTitle(extras.getString("title")) .setSummaryText(stacking); for(Object noticationMensage : messageList){ notificationInbox.addLine(Html.fromHtml(noticationMensage.toString())); } mBuilder.setStyle(notificationInbox); mBuilder.setLargeIcon(null); } } } catch(NumberFormatException e) { Log.e(LOG_TAG, "Number format exception - Error parsing Group: " + e.getMessage()); } catch(Exception e) { Log.e(LOG_TAG, "Number format exception - Error parsing Group" + e.getMessage()); } if (message != null) { mBuilder.setContentText(message); mBuilder.setContentText(Html.fromHtml(message)); } else { mBuilder.setContentText("<missing message content>"); } Loading
src/android/com/adobe/phonegap/push/PushHandlerActivity.java +2 −0 Changes for src/android/com/adobe/phonegap/push/PushHandlerActivity.java: 2 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -20,6 +20,8 @@ public class PushHandlerActivity extends Activity */ @Override public void onCreate(Bundle savedInstanceState) { GCMIntentService gcm = new GCMIntentService(); gcm.setNotification(""); super.onCreate(savedInstanceState); Log.v(LOG_TAG, "onCreate"); Loading