Hello.
I’ve been developing a Ionic app a while ago, and I’m using the Firebase plugin from Ionic.
When I open the app, I have in the constructor of my first page :
if (this.platform.is('cordova')) {
this.firebase.onTokenRefresh()
.subscribe((tok) => {
this.token = tok;
storage.set('token', tok);
firebase.subscribe("all");
});
}
I guess it is working fine; plus, when I display
this.firebase.getToken()
.then((val) => { this.debug.push("App token (refreshed): "+val) })
.catch((error) => { this.debug.push("Error while getting app token: "+error) });
I get a token that seems alright (152 in length, seems to be a number that other people have too).
Lastly, when I use the firebase console to send a message to all the devices, my application receives the notification.
However, if I try to send the same notification to my single device by using this token I’m retrieving, I just get an error saying the registration token is incorrect.
Where could this come from ?
Edit: from a FCM page I’ve seen the following statement:
// If you want to send messages to this application instance or
// manage this apps subscriptions on the server side, send the
// Instance ID token to your app server.
sendRegistrationToServer(refreshedToken);
I haven’t done anything of this kind with Ionic because I don’t know if there’s such a command. It could explain easily the problem, but then I would need an answer to it because I haven’t seen an equivalent to that command in the plugin page. If it’s just here to suggest us to store the token in a db, then this is not what I’m looking for. My problem is more like the token has been “uploaded to FCM servers”