diff --git a/src/android/com/adobe/phonegap/push/PushConstants.java b/src/android/com/adobe/phonegap/push/PushConstants.java index 33c6fcdd8..3280e6618 100644 --- a/src/android/com/adobe/phonegap/push/PushConstants.java +++ b/src/android/com/adobe/phonegap/push/PushConstants.java @@ -55,7 +55,7 @@ public interface PushConstants { public static final String FROM = "from"; public static final String COLLAPSE_KEY = "collapse_key"; public static final String FORCE_SHOW = "forceShow"; - public static final String GCM = "GCM"; + public static final String FCM = "FCM"; public static final String CONTENT_AVAILABLE = "content-available"; public static final String TOPICS = "topics"; public static final String SET_APPLICATION_ICON_BADGE_NUMBER = "setApplicationIconBadgeNumber"; diff --git a/src/android/com/adobe/phonegap/push/PushPlugin.java b/src/android/com/adobe/phonegap/push/PushPlugin.java index 70b6182a0..ecc4b9623 100644 --- a/src/android/com/adobe/phonegap/push/PushPlugin.java +++ b/src/android/com/adobe/phonegap/push/PushPlugin.java @@ -72,6 +72,10 @@ public void run() { token = FirebaseInstanceId.getInstance().getToken(); + if (token == null) { + token = FirebaseInstanceId.getInstance().getToken(senderID,FCM); + } + if (!"".equals(token)) { JSONObject json = new JSONObject().put(REGISTRATION_ID, token); @@ -88,6 +92,9 @@ public void run() { } catch (JSONException e) { Log.e(LOG_TAG, "execute: Got JSON Exception " + e.getMessage()); callbackContext.error(e.getMessage()); + } catch (IOException e) { + Log.e(LOG_TAG, "execute: Got IO Exception " + e.getMessage()); + callbackContext.error(e.getMessage()); } if (jo != null) {