Describe the bug
If my understanding is correct, onTokenRefresh() should only be called when a new token is generated. However, while testing on iOS, this method observable is being called every time I close and reopen the application. It doesnt run the token method if I go from App -> Home Screen -> App. But if I go App -> Swipe to close app -> Reopen application then it runs (but it's still the same token instance). I thought this method should only run if the instance token actually needs to be changed?
I've confirmed that the token is not updating by comparing the token instance ID that is printed to XCode console to the one that is currently saved in my database.
To Reproduce
Steps to reproduce the behavior:
In my app.component.ts I subscribe to an auth method from firebase that returns a user object
this.auth.user$.subscribe(
(user) => {
if (user) {
this.fcm.getToken(user)
}
})
in my fcm.service I then subscribe to the onTokenRefresh():
import { Firebase } from '@ionic-native/firebase/ngx';
constructor(public firebaseNative: Firebase) { }
async getToken(user) {
this.firebaseNative.onTokenRefresh().subscribe((instanceToken) => {
alert('Token has been refreshed')
})
...
}
And every time I open my application, the Token has been refreshed text is printed to the alert.
Here's a video, every time I close out the app and reopen, the token is printed as an alert notice how the token is the exact same on each one but for some reason even though it's the same token that onTokenRefresh is being called..:
Expected behavior
Token refresh method should only be triggered when a new token instance is generated. Such as when I'm deleting and reinstalling my app.
Screenshots
token instance shown in Xcode console:
token instance in my database:
Plugin Version
Run cordova plugin list to find out what version of cordova-plugin-firebase you are running with
Describe the bug If my understanding is correct,
onTokenRefresh()
should only be called when a new token is generated. However, while testing on iOS, this method observable is being called every time I close and reopen the application. It doesnt run the token method if I go from App -> Home Screen -> App. But if I go App -> Swipe to close app -> Reopen application then it runs (but it's still the same token instance). I thought this method should only run if the instance token actually needs to be changed?I've confirmed that the token is not updating by comparing the token instance ID that is printed to XCode console to the one that is currently saved in my database.
To Reproduce Steps to reproduce the behavior:
In my
app.component.ts
I subscribe to an auth method from firebase that returns a user objectin my
fcm.service
I then subscribe to theonTokenRefresh()
:And every time I open my application, the
Token has been refreshed
text is printed to the alert.Here's a video, every time I close out the app and reopen, the token is printed as an alert notice how the token is the exact same on each one but for some reason even though it's the same token that
onTokenRefresh
is being called..:https://streamable.com/xawbe
Expected behavior Token refresh method should only be triggered when a new token instance is generated. Such as when I'm deleting and reinstalling my app.
Screenshots token instance shown in Xcode console:
token instance in my database:
Plugin Version Run
cordova plugin list
to find out what version of cordova-plugin-firebase you are running withcordova-plugin-firebase 2.0.5 "Google Firebase Plugin"
Desktop (please complete the following information):
Smartphone (please complete the following information):