Solution was:
// In your App.xaml.cs
public partial class App : MauiWinUIApplication
{
// ...
protected override async void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
{
var appInstance = AppInstance.GetCurrent();
var e = appInstance.GetActivatedEventArgs();
// If it's not a Protocol activation, just launch the app normally
if (e.Kind != ExtendedActivationKind.Protocol ||
e.Data is not ProtocolActivatedEventArgs protocol)
{
appInstance.Activated += AppInstance_Activated;
base.OnLaunched(args);
return;
}
// If it's a Protocol activation, redirect it to other instances
var instances = AppInstance.GetInstances();
await Task.WhenAll(instances
.Select(async q => await q.RedirectActivationToAsync(e)));
return;
}
private void AppInstance_Activated(object? sender, AppActivationArguments e)
{
if (e.Kind != ExtendedActivationKind.Protocol ||
e.Data is not ProtocolActivatedEventArgs protocol)
{
return;
}
// Process your activation here
Debug.WriteLine("URI activated: " + protocol.Uri);
}
}
Also answered here: https://stackoverflow.com/a/79123126/17302880