Hello,
First thank you for the tutorial. It helped me a lot in a project im doing.
Can you please help me with a problem i have redirecting to another view (with parameters) when push is received??
firebase.init({
..............
onMessageReceivedCallback: function(message) {
let router:Router;
let navigationExtras: NavigationExtras = {
queryParams: {
"url": 'http:www.google.com/',
}
};
router.navigate(["view-name"], navigationExtras);
}
.........
)}
im getting cannot read property of router "undefined"
Please help!
@krisidmisso have you found the solution for this problem?
@krisidmisso did you try to inject router in constructor like this?
constructor(
private router: Router
) { }
@hedza06 you can make a separate function and use fat arrow functions:
onMessageReceivedCallback: (message)=>{
this.navigateTo();
}
.....
function navigateTo() {
let router:Router;
let navigationExtras: NavigationExtras = {
queryParams: {
"url": 'http:www.google.com/',
}
};
router.navigate(["view-name"], navigationExtras);
}
The problem i have still today is that this works on debug mode, or when build with webpack bundle.....but it doesnt work when i publish the app in app store.
Hope it helps
@krisidmisso Did you set the APN in firebase before publishing?
@hedza06 Im using only Android for the moment. No need for apn :)
Were you able to find a solution? I have the same problem.
@lumayara are you using angular? if yes, you have to follow exactly the installation guide, and then add this to a component(page) that is opened always (main.ts / app.component.ts / app.module.ts...in my case its home.component.ts):
....
....
let firebase = require("nativescript-plugin-firebase");
....
....
....
export class HomeComponent {
constructor(private router: Router) {
//firebase init function
//handle push notification tap event
firebase.addOnMessageReceivedCallback(
(message) => {
// navigate to a route
this.router.navigate(["other-page"]);
}
);
}
}
Most helpful comment
@lumayara are you using angular? if yes, you have to follow exactly the installation guide, and then add this to a component(page) that is opened always (main.ts / app.component.ts / app.module.ts...in my case its home.component.ts):