How to use xamarin push notification to specific page in the app?

Baha Masoud 41 Reputation points

I could not find anything or was outdated on when the app is in the background or not running, the user clicks the notification icon, and will be directed to a specific page inside the app (every time the page might be different), i am not sure where to look, is it the template that needed to be modified or additional code?

thanks for any tips.

Azure Notification Hubs
Azure Notification Hubs
An Azure service that is used to send push notifications to all major platforms from the cloud or on-premises environments.
279 questions
{count} votes

4 answers

Sort by: Most helpful
  1. Baha Masoud 41 Reputation points

    Currently, my Xamarin app is working fine receiving notifications. but the main page is always opening when I click the notification from the background.
    and like i said, i could not find any code in xamarin forum regarding adding a link with the notification except for a question from a few years ago (does not work anymore):


  2. Gaurav Khanna 6 Reputation points

    As main page is getting opened when you click on notification, you can add code in your main page to navigate to the page of your choice when you receive message/notification.

    Following link has nice explanation with steps


    0 comments No comments

  3. Baha Masoud 41 Reputation points

    Do you mean that the message body in the notifications should include the link, and when I call:
    messageBody = message.Data.Values.First();

    then somehow I need to separate the notification text from the link?

    0 comments No comments

  4. SnehaAgrawal-MSFT 19,361 Reputation points

    Thanks for reply. As mentioned in the document when Configuring the Android application for notifications in Override FirebaseMessagingService to handle messages

    The Incoming messages are converted to a local notification with the SendLocalNotification method. This method creates a new Intent and places the message content into the Intent as a string Extra. When the user taps the local notification, whether the app is in the foreground or the background, the MainActivity is launched and has access to the message contents through the Intent object. This also sends the message directly to the current MainPage instance with the SendMessageToMainPage method.

    If you want to redirect to a specific page when the app is opened try overriding OnNewIntent method in MainActivity class and navigation

    Xamarin.Forms.Application.Current.MainPage.Navigation.PushAsync(new Views.AboutPage());

    Refer to below discussion links might be helpful:

    0 comments No comments