FirebasePushNotificationPlugin icon indicating copy to clipboard operation
FirebasePushNotificationPlugin copied to clipboard

Redirect to a specific page in a webview when open a notification

Open LucioOrtizGit opened this issue 3 years ago • 0 comments

Is it possible to redirect to a specific page of the app that is in a webview when opening a notification, both with the app in the background and in the foreground?

I know that the notification that is opened with the app in the foreground is handled with the CrossFirebasePushNotification.Current.OnNotificationReceived method. In this method I can get the link of the notification body but I don't know how to reload the webview.

When the notification opens with the app in the background, it reaches the OnCreate method of the MainActivity, in which I don't know how to obtain the body of the notification that contains the link to navigate to, but from here the webview can be reached correctly.

notificacion on foreground

CrossFirebasePushNotification.Current.OnNotificationReceived += (s, p) =>
 {
   if (p.Data.ContainsKey("body"))
   {                                  
                            string link = p.Data["body"].ToString();

                            GlobalElements.direccionURL = link;

                            string pagina = App.Current.MainPage.Navigation.NavigationStack.LastOrDefault().ToString();

                           ....
    }
};

notificacion on background

  protected override void OnCreate(Bundle bundle)
    {
          .....
           LoadApplication(new App());

           FirebasePushNotificationManager.ProcessIntent(this, Intent);

           .....
   }

I'm not sure how to get to the specific page of the webview Thanks for the help.

LucioOrtizGit avatar Nov 16 '22 17:11 LucioOrtizGit