Share via

Deep linking windows

Eduardo Gomez 4,316 Reputation points
2024-01-12T19:30:19.1133333+00:00

Thanks to @Anonymous , I was able to do this for Android I am trying to figure out, how to do it for Windows.
I tried this. Package.appxmanifest

	<Extensions>
		<uap:Extension Category="windows.protocol">
			<uap:Protocol Name="demyai"/>
		</uap:Extension>




        builder
                .UseMauiApp<App>()
                .ConfigureLifecycleEvents(events => {

#if  WINDOWS
                    events.AddWindows(windows => windows
                           .OnLaunched((window, args) => {

                               var activatedEventArgs = Microsoft.Windows.AppLifecycle.AppInstance.GetCurrent().GetActivatedEventArgs();

                           }));
#endif

but my ativatedEventargs is null

Developer technologies | .NET | .NET Multi-platform App UI
0 comments No comments

Answer accepted by question author

Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 50,166 Reputation points Microsoft External Staff
2024-01-15T02:35:48.95+00:00

Hello,

This is a known issue in WinUI.

According to Can't get parameters on URI activation #8855, you could use Environment.GetCommandLineArgs() to get the startup parameters.

Please refer to the following code:

#if WINDOWS
                    events.AddWindows(windows => windows.
                    OnLaunched((window, args) =>
                    {
                       
                        var p = Environment.GetCommandLineArgs();
                        if (p != null)
                        {
                            Console.WriteLine(p);
                        }
                    }));
#endif

After testing, when the program is started with demyai://?para=test, the variable p can get this URI parameter.

Best Regards,

Alec Liu.


If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

Was this answer helpful?


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.