Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

Commit

Permalink
Fixed empty token on android first run (#1008)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile authored and macdonst committed Dec 1, 2016
1 parent b6acbfe commit fda1f90
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/android/com/adobe/phonegap/push/PushConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
7 changes: 7 additions & 0 deletions src/android/com/adobe/phonegap/push/PushPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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) {
Expand Down

0 comments on commit fda1f90

Please sign in to comment.