Meridith Spellerberg
Meridith Spellerberg

Reputation: 101

How to get parameters of a URI deep link into a Maui Application?

I am want to create a deep link like some-app://localhost?user=123455 that when clicked opens a Maui WinUI app. When the app receives this deep link I want to be able to get the user ID off of the deep link. I was able to do this in Xamarin, but haven't figured out the Maui equivalent

I am able to register the app using (taken from this Windows doc):

   <Applications>
    <Application Id= ... >
        <Extensions>
            <uap:Extension Category="windows.protocol">
              <uap:Protocol Name="alsdk">
                <uap:Logo>images\icon.png</uap:Logo>
                <uap:DisplayName>SDK Sample URI Scheme</uap:DisplayName>
              </uap:Protocol>
            </uap:Extension>
      </Extensions>
      ...
    </Application>

But when I receive the event via the app lifecycle (https://learn.microsoft.com/en-us/dotnet/maui/fundamentals/app-lifecycle#windows) I am not seeing the parameters of the URI.

Upvotes: 2

Views: 1863

Answers (1)

Antoine Valente
Antoine Valente

Reputation: 11

I've encountered the same problem and I got it working thanks to this reply on the issue I created.

You can retrieve the launch arguments by using Environment.GetCommandLineArgs(); inside of OnLaunched.

Upvotes: 1

Related Questions