Hi @EddyVerbruggen
I am trying to use your plugin use firebase messaging but I can't test the notification push because I never got the the device token.
I went through all the other issues talking about the same thing but I still have the same problem.
I suspect the version I am using but I'm not sure, could you please have a look ?
Here it's my package.json:
```{
"nativescript": {
"id": "ma.redouane.test",
"tns-android": {
"version": "5.4.0"
},
"tns-ios": {
"version": "5.4.2"
}
},
"description": "NativeScript Application",
"license": "SEE LICENSE IN
"repository": "
"scripts": {
"lint": "tslint \"src/*/.ts\""
},
"dependencies": {
"@angular/animations": "~8.0.0",
"@angular/common": "~8.0.0",
"@angular/compiler": "~8.0.0",
"@angular/core": "~8.0.0",
"@angular/forms": "~8.0.0",
"@angular/http": "~8.0.0-beta.10",
"@angular/platform-browser": "~8.0.0",
"@angular/platform-browser-dynamic": "~8.0.0",
"@angular/router": "~8.0.0",
"nativescript-angular": "~8.0.0",
"nativescript-plugin-firebase": "^9.0.1",
"nativescript-push-notifications": "^1.1.6",
"nativescript-theme-core": "~1.0.4",
"reflect-metadata": "~0.1.12",
"rxjs": "~6.5.0",
"tns-core-modules": "~5.4.0",
"zone.js": "~0.9.1"
},
"devDependencies": {
"@angular/compiler-cli": "~8.0.0",
"@ngtools/webpack": "~8.0.0",
"codelyzer": "~4.5.0",
"nativescript-dev-sass": "~1.7.0",
"nativescript-dev-typescript": "~0.10.0",
"nativescript-dev-webpack": "~0.24.0",
"tslint": "~5.11.0"
},
"gitHead": "8c1a4866a66daab09bf5ef8e5a96472687192373",
"readme": "NativeScript Application"
}
I have this in `app.component.ts`:
``` ngOnInit(): void {
// Init your component properties here.
firebase.init({
showNotifications: true,
showNotificationsWhenInForeground: true,
onPushTokenReceivedCallback: (token) => {
console.log('[Firebase] onPushTokenReceivedCallback:', { token });
},
onMessageReceivedCallback: (message: firebase.Message) => {
console.log('[Firebase] onMessageReceivedCallback:', { message });
}
})
.then(() => {
console.log('[Firebase] Initialized');
})
.catch(error => {
console.log('[Firebase] Initialize', { error });
});
}
For tests, I'm using android studio emulator with API level 28 on Nexus 5 (play services included).
I have the same issue as @RedouaneM on Android (emulator and real device). However, on iOS everthing works fine. I use version 9.0.1.
Please share a repo and instructions on how I can reproduce it.
I'll try to look at this as soon as possible, but a repo would be very helpful.
I think it's a timing issue; you may be registering the onPushTokenReceivedCallback handler after Firebase has sent the token to the device. So for these cases I'll simply check if there's a token already when registering and send that to the callback. Will be available in 9.0.2 shortly.
@EddyVerbruggen I just tested 9.0.2 on Android and now it works as expected. Great work, thanks!
Most helpful comment
I think it's a timing issue; you may be registering the
onPushTokenReceivedCallbackhandler after Firebase has sent the token to the device. So for these cases I'll simply check if there's a token already when registering and send that to the callback. Will be available in 9.0.2 shortly.