stefischer
stefischer

Reputation: 41

How define a start page for PWA dynamically

I have created project "Progressive Web App" based on JavaScript with Visual Studio 2017. The created project contains a file "package.appxmanifest". In this file a StartPage is defined. Is it possible to dynamically set this StartPage when the user installs the app?

Upvotes: 2

Views: 510

Answers (1)

Anran Zhang
Anran Zhang

Reputation: 7737

You can't dynamically set the StartPage within the package.appxmanifest.

You can think of a UWP project created with PWA as a directed browser. The launch of the page is done in Javascript. So if you want to redirect the page, you should also do it in Javascript.

If you add your web address to package.appxmanifest -> Content URIs and have access to WinRT APIs, you can listen for navigated event.

window.onload = function () {
    if (window.Windows) {
        Windows.UI.WebUI.WebUIApplication.addEventListener("navigated", function (navigatedEventArgs) {
            // navigate to other page
        });
    }
}

Best regards.

Upvotes: 1

Related Questions