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

data.registrationId is empty string "" on register event callback #295

Closed
kentmw opened this issue Nov 2, 2015 · 2 comments
Closed

data.registrationId is empty string "" on register event callback #295

kentmw opened this issue Nov 2, 2015 · 2 comments

Comments

@kentmw
Copy link

kentmw commented Nov 2, 2015

For Android, I was receiving an empty string "" on the register callback. Everytime I initialized the plugin, it would consistently return an empty string. When I un-installed the app and re-installed it, I received an actual token.

I don't know why this would occur, but I wanted to report it.

I think it has to do with the fact that register call in PushPlugin.java uses SharedPreferences to return a stored registration id. If, for some reason, both of the top two if statements fail in the following code block, it will just rely on (hope that there is) a stored registration id.

See PushPlugin.java:

// first time run get new token
if ("".equals(savedSenderID) && "".equals(savedRegID)) {
  token = InstanceID.getInstance(getApplicationContext()).getToken(senderID, GCM);
}
// new sender ID, re-register
else if (!savedSenderID.equals(senderID)) {
  token = InstanceID.getInstance(getApplicationContext()).getToken(senderID, GCM);
}
 // use the saved one
else {
  token = sharedPref.getString(REGISTRATION_ID, "");
}
@macdonst
Copy link
Member

macdonst commented Nov 2, 2015

@kentmw fixed in 1.4.1 which has been pushed to NPM

@macdonst macdonst closed this as completed Nov 2, 2015
chaffeqa added a commit to sportstech/phonegap-plugin-push that referenced this issue Nov 3, 2015
* 'master' of github.com:phonegap/phonegap-plugin-push:
  Version 1.4.2
  Issue phonegap#299: 1.4.x not showing notification on Android
  Version 1.4.1
  Issue phonegap#295: data.registrationId is empty string "" on register event callback
  Issue phonegap#291: Reregister on Android
  [typo] fixing .finish() example
  Update CHANGELOG
  Version 1.4.0
  Issue phonegap#93: Receive Notifications in Background
@lock
Copy link

lock bot commented Jun 5, 2018

This thread has been automatically locked.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants