What is the proper way to retrieve a token after it's been registered?

After your push token has been registered, what is the proper way to retrieve the token again for future use?

Previously, you were able to call a getStorageToken() function to retrieve the saved token on the device. With the new $ionicCloud method, it does not appear as if that is an option.

Can someone point me in the right direction for a better understanding of how to get an already saved token on the device?


This may give a pointer:

https://docs.ionic.io/services/push/#registering-device-tokens says

We store the generated device token with the current user when the token is saved.

Thanks for the reply @Sujan12.

I am not really sure if that leads me down a better path, or not.

So, if I use this code to register my push token:

$ionicPush.register().then(function(t) {
  return $ionicPush.saveToken(t);
}).then(function(t) {
  console.log('Token saved:', t.token);

What could should I be using elsewhere to get that token again? Can I reuse the above the code again in another section of my app to get the already created token?

2 ways:

  1. Change that code so that it saves the token somewhere where you can access and use it later.
  2. Find out what

means exactly so you can find out how to call this “user” and the data saved in it. (I would assume it has to do with Ionic Auth, but I am not sure - never used that part.)

It appears that I was making this far too difficult.

I simply used the code $ionicPush.token.token to access to the token after it was registered.

1 Like