October 2017
Intermediate to advanced
302 pages
7h 27m
English
We'll do something similar with updating a token, but this time we need to access the existing token in the database.
Add a console.log here for testing purposes:
saveTokenToServer() { this.messaging.getToken().then(res => { if (this.tokensLoaded) { const existingToken = this.findExistingToken(res); if (existingToken) { console.log(existingToken); } else { this.registerToken(res); } } }); }
Then, try logging in and out of the app with different users. You should see the same existingToken key each time:

We can use this to grab the existing entry from the fcmToken table in our database, and update it:
saveTokenToServer() ...
Read now
Unlock full access