Closed longcharmroeun closed 3 years ago
onTokenRefresh
is never called, as the token doesn't rotate see the depreciation notice on the JS SDK docs.
Use the tokenChanges
observable.
this.afMessaging.tokenChanges.subscribe((x) => {
console.log('Hello');
});
this.afMessaging.requestToken.subscribe(
() => {},
(error) => {
console.error(error);
}
);
or switchmap to our getToken observable
this.afMessaging.requestToken.pipe(
switchMapTo(this.afMessaging.getToken)
).subscribe(
token => {
console.log('hello', token);
},
(error) => {
console.error(error);
}
);
I realize things here are a bit confusing, since Firebase v8 changed a lot with the messaging APIs and we're currently supporting v7 too.
i spend my whole day on it , next time just make it deprecated
label xd
Version info
Angular: 11.0.2
Firebase: 8.1.1
AngularFire: 6.1.2
Other (e.g. Ionic/Cordova, Node, browser, operating system):
Node: 12.18.4
Browser: Google Chrome
Operating system: Windows10
How to reproduce these conditions
I want to save Cloud Messaging token to server when user clear data, uninstall/install ... so i use onTokenRefresh Event to save token.
Steps to set up and reproduce
Simple Code
Sample data and security rules
No required Sample data and security rules
Debug output
No output show
Expected behavior
It should output
Hello
when clear data and reset permissionActual behavior
No output show
it have been post to firebase server but onTokenRefresh not fire![ClientApp - Google Chrome 11_26_2020 9_57_09 AM](https://user-images.githubusercontent.com/42161560/100302948-f7f8a200-2fcd-11eb-937c-e79f8ccc1a29.png)