Search code examples
c#androidxamarinxamarin.formsdeep-linking

Deep Linking "OnAppLinkRequestReceived" method is not executed in Xamarin app with LaunchMode = SingleTop


I have a Xamarin Forms App for android with LaunchMode = SingleTop in MainActivity.cs. When the app in invoked for the first time via Deep linking URL, the method OnAppLinkRequestReceived is executed in App.XAML.cs file. In this method I'm setting some app parameters received from URL.

Once I open the app and push it to background using Home button and call the URL again, the app which is running in the background is made active, but the method OnAppLinkRequestReceived is not executed at all. So, I was not able to change the app parameters.

When I kill the app and open the URL again, a new instance of the app is created and OnAppLinkRequestReceived is executed.

Is there any way to invoke OnAppLinkRequestReceived each time the app URL is called, irrespective of whether the app is already running or not ?


Solution

  • The method OnNewIntent in MainActivity.cs is blank earlier. I added a call to the base method.

    Now, when I try to reopen the app from background, the method OnAppLinkRequestReceived is executed.

    protected override void OnNewIntent(Intent intent)
     {
         // Added this line
         base.OnNewIntent(intent);
     }