I am testing App Links / Deep Linking / Universal Links on my Xamarin Forms app. I have an app that correctly intercepts URLs as expected, but when I go to navigate to the page using Shell in my app, Shell.Current is null.
Visual Studio 2022, Android Pixel 4 emulator, Xamarin Forms version 5.0.0.2291
Setup: Simple onAppLinkRequestReceived handler. The debugger executes and breaks at this code, so I know my applinks are set up properly.
protected override async void OnAppLinkRequestReceived(Uri uri)
{
base.OnAppLinkRequestReceived(uri);
var shellRoute = uri.PathAndQuery;
try
{
Log.Information("User followed applink for {shellRoute}", shellRoute);
Shell.Current.GoToAsync(shellRoute);
}
catch(Exception ex)
{
Log.Error(ex, "User encountered an error attempting to navigate to an applink request", shellRoute);
}
}
The problem here is that Shell.Current is null so I nullref. I expect shell.current should always be valid?
I am testing this using Android's suggested test technique, found here:
.\adb shell am start -W -a android.intent.action.VIEW -d "my-url" my-package-id
a null shell current value appears unexpected especially when other examples on the web indicate that navigation straight from the applinkrequest event should be valid?