diff --git a/src/android/com/adobe/phonegap/push/PushPlugin.java b/src/android/com/adobe/phonegap/push/PushPlugin.java index becd03c54..d81a06198 100644 --- a/src/android/com/adobe/phonegap/push/PushPlugin.java +++ b/src/android/com/adobe/phonegap/push/PushPlugin.java @@ -80,11 +80,15 @@ else if (!savedSenderID.equals(senderID)) { token = sharedPref.getString(REGISTRATION_ID, ""); } - JSONObject json = new JSONObject().put(REGISTRATION_ID, token); + if (!"".equals(token)) { + JSONObject json = new JSONObject().put(REGISTRATION_ID, token); - Log.v(LOG_TAG, "onRegistered: " + json.toString()); + Log.v(LOG_TAG, "onRegistered: " + json.toString()); - PushPlugin.sendEvent( json ); + PushPlugin.sendEvent( json ); + } else { + callbackContext.error("Empty registration ID received from GCM"); + } } catch (JSONException e) { Log.e(LOG_TAG, "execute: Got JSON Exception " + e.getMessage()); callbackContext.error(e.getMessage());