question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Navigate to route (view) when push notification is received??

See original GitHub issue

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!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:7

github_iconTop GitHub Comments

5reactions
krisidmissocommented, Aug 3, 2018

@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"]);
      }

    );
}
}
0reactions
lumayaracommented, Aug 3, 2018

Were you able to find a solution? I have the same problem.

Read more comments on GitHub >

github_iconTop Results From Across the Web

route when push notification is opened · Issue #742 - GitHub
I use redux, and have a handler for the push-notification which triggers a navigation-action, works pretty smooth - although the correct view is ......
Read more >
React Native - How to open route from push notification
In my situation, I wanted to get the data once the notification is been opened and then navigate according to that and it...
Read more >
Open app in specific view when push notification is tapped
Say you have an app and want to redirect user to a specific view when a push notification is tapped, eg: going to...
Read more >
Deep Linking Push Notifications with React Navigation - Medium
To test this, go to Firebase console, to the project that's linked to this app (URL looks something like this: https://console.firebase.google.
Read more >
Start an Activity from a Notification - Android Developers
When you start an activity from a notification, you must preserve the user's expected navigation experience. Tapping Back should take the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found