Search code examples
javascriptwinjs

How to launch a winstore app from within another winstore app


I am currently building a win-store app for a client, and I can't seem to figure out how to link to another app from within my current app.

I have seen plenty of documentation on how to open the default application from a URI or file type but nothing on opening a specific app.

Currently I am able to open my app with the function below, after adding a protocol to the declarations in my package.appxmanifest, but this isn't the preferred solution since this will not cause the app to open in full screen.

function openApp() {

    var options = new Windows.System.LauncherOptions();
    options.preferredApplicationPackageFamilyName = "packageFamilyName";
    options.preferredApplicationDisplayName = "App Display Name";

    var uri = new Windows.Foundation.Uri("linktomyapphere:");


    Windows.System.Launcher.launchUriAsync(uri).then(
        function (e) {},
        function (err) {
            console.log(err);
        });

}


Solution

  • The best way is definitely URL activation (aka protocol activation). If you own the other app, you register a protocol for it - something like myapp://. That is done in the manifest. Then you follow the instructions on this page to activate that from your app. You can even pass URL parameters so you can pass some state in during activation.