How to navigate to specific page by clicking on push notification


#1

Hi all,

I just started using push notification on Android and everything works fine. I just have one problem, if app is in background and I receive notification, I want to open specific page by clicking on that notification. I know i should use ‘click_action’ by I am struggling figure out with android activities. I know I have to create custom or I am on the wrong track. Any help or advise is highly appreciated. Thanks


#2

You can simply perform the navigation on the notification received callback.


#3

@manojdcoder Thanks for quick reply and suggestion. The problem is that I am passing “data” and “notification” with push notification. If I remove “notification” it works as you said, but then push notification doesn’t appear when app is killed which is crucial for my app. If I pass both “data” and “notification” I don’t get callback when app is in background. I tried to follow this post https://stackoverflow.com/questions/37711082/how-to-handle-notification-when-app-in-background-in-firebase but no results. Do you have any ideas? Thanks


#4

If you remove notification attribute, it becomes a silent push so it won’t show a notification in tray by default. Your callback will be triggered only when user clicks on the notification in tray if app is in background / killed.


#5

At the moment, if app is in background and I click on push notification, app becomes active and callback is not triggered. What I am doing wrong?


#6

It should work, it does on my apps where I just followed the docs.

You are having problems with iOS / Android / Both? Did you try the demo app with your firebase config?


#7

I have implemented only Android for now. I haven’t tried demo app yet as everything worked as expected. I will try demo app and if I still have problems I will let you know. Thank you


#8

Hello,

I Don’t know if this helps but :
When the notification is received and the callback is triggered you can put your link data in the activity intent extras (for android).
Then on activityResumedEvent you can check for this data and then do your navigation (and remove the intent extras as well).
It should do the navigation when you tap the notification.