Opening an app from other app using protocol

BitSmithy 1,976 Reputation points
2024-07-25T18:55:44.9433333+00:00

Hello,

I am trying to open app from other app where the opened app has a protocol defined in its manifest.

I use such code:

        public async void OpenOrShowInStore(string customCampaignId)
        {
            //if not instaled go to
            LauncherOptions options = new LauncherOptions();

            if (customCampaignId == "")
            {
                options.FallbackUri = appWinStoreProtocolUri;
            }
            else
            {
                if (Uri.TryCreate(appWinStoreProtocolUri.OriginalString + "&cid=" + customCampaignId, UriKind.RelativeOrAbsolute, out Uri newUri))
                {
                    var a = newUri.OriginalString;

                    options.FallbackUri = newUri;

                }
                else
                    options.FallbackUri = appWinStoreProtocolUri;
            }

            var success = await Windows.System.Launcher.LaunchUriAsync(appUri, options);
        }

The protocol is defined in opened app manifest in declaration section.

Main app is instaled as flight package, opened app is instaled as flight package too.

OnActivated(IActivatedEventArgs args) event isnt implemented in opened app because I do nothing when I open the app, I want simplu opent it.

Result of my code is such that opened app opens, but is stuck on splash screen.

How to fix this problem?

Universal Windows Platform (UWP)
0 comments No comments
{count} votes