Commit a412c1c7 authored by Bob Easterday's avatar Bob Easterday
Browse files

Don't choke if no msgcnt or message values are passed in the notification

parent 778bbbb9
Loading
Loading
Loading
Loading
+1 −1
Changes for Example/www/index.html: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -89,7 +89,7 @@
					if ( e.regid.length > 0 )
					{
						$("#app-status-ul").append('<li>REGISTERED -> REGID:' + e.regid + "</li>");
						console.log("regID = " + regID);
						console.log("regID = " + e.regID);
						// Your GCM push server needs to know the regID before it can push to this device
						// here is where you might want to send it the regID for later use.
					}
+16 −2
Changes for src/android/com/google/android/gcm/GCMIntentService.java: 16 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -102,10 +102,24 @@ public class GCMIntentService extends GCMBaseIntentService {
		.setWhen(System.currentTimeMillis())
		.setContentTitle(appName)
		.setTicker(appName)
		.setContentText(extras.getString("message"))
		.setNumber(Integer.parseInt(extras.getString("msgcnt")))
		.setContentIntent(contentIntent);
		
		String message = extras.getString("message");
		if (message != null)
		{
			mBuilder.setContentText(message);
		}
		else 
		{
			mBuilder.setContentText("<missing message content>");
		}

		String msgcnt = extras.getString("msgcnt");
		if (msgcnt != null)
		{
			mBuilder.setNumber(Integer.parseInt(msgcnt));
		}
		
		mNotificationManager.notify(notificationID, mBuilder.build());
	
		try
+2 −0
Changes for src/android/com/plugin/GCM/PushPlugin.java: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -75,6 +75,8 @@ public class PushPlugin extends Plugin {
    else if (UNREGISTER.equals(action)) {

      GCMRegistrar.unregister(this.ctx.getContext());
      GCMRegistrar.onDestroy(this.ctx.getContext());
      
      Log.v(ME + ":" + UNREGISTER, "GCMRegistrar.unregister called ");
      result = new PluginResult(Status.OK);
    }