I've created a Maui windows application. I'm looking to activate the application through a URI and pass query parameters to the app.
I've added the windows protocol for calling the app via uri in the package manifest:
<Extensions>
<uap:Extension Category="windows.protocol">
<uap:Protocol Name="my-app">
<uap:DisplayName>My App</uap:DisplayName>
</uap:Protocol>
</uap:Extension>
</Extensions>
When I activate the application via the browser my-app://foo.com?user=123456 the app launches, but it launches as a cold start. Within my Win UI app I've overrode the onLaunched method, but regardless of how I've launched the app I cannot get access to the protocol. I'm trying to recreate the following code from my UWP Application:
protected override void OnActivated(IActivatedEventArgs args)
{
if (args.Kind == ActivationKind.Protocol)
{
ProtocolActivatedEventArgs eventArgs = args as ProtocolActivatedEventArgs;
var queryStr = eventArgs.Uri.Query;
App.UserId = System.Web.HttpUtility.ParseQueryString(queryStr).Get("user");
// Navigate to a view
Frame rootFrame = Window.Current.Content as Frame;
if (rootFrame == null)
{
rootFrame = new Frame();
Xamarin.Forms.Forms.Init(args);
Window.Current.Content = rootFrame;
}
rootFrame.Navigate(typeof(MainPage), eventArgs);
}
Window.Current.Activate();
}
So I've started with this, but UWPLaunchActivatedEventArg is consistently being returned as Launch instead of protocol.
protected override void OnLaunched(LaunchActivatedEventArgs args)
{
var kind = args.UWPLaunchActivatedEventArgs.Kind;
base.OnLaunched(e)
}
