Skip to main content

SDK on your prelanding

Usually a visitor lands on a prelanding and moves from there to the PWA store card, where the install button lives. But the install and the push subscription can be launched right on your own prelanding: you connect the Browser SDK and call its methods from your own buttons. Then the visitor installs the app and subscribes to push without leaving for the store card.

The visitor does not have to install the app for this: push subscription works without it.

What you need first

  • A prelanding uploaded to Qubix. This is your page in the Websites section — upload it the same way as an ordinary site (see Uploading a website).
  • A domain that is set up and active. The prelanding must be served on a domain that is set up in Qubix and active (see Domains). This is required: install and push work only when the page and the SDK's service addresses are on the same domain.
  • A PWA created — you will need its identifier (pwaId) from the card in the PWA Apps section.

How to connect

  1. In the prelanding's code, set the config and load the SDK script. The config goes before the script:

    index.htmlHTML
    <script>
    window.pwaConfig = {
    pwaId: 'YOUR-PWA-ID',
    domain: 'your-domain.com',
    }
    </script>
    <script src="https://your-domain.com/sdk.js" defer></script>

    The push key is inlined into /sdk.js automatically — you do not need to add it by hand. A full breakdown of the fields is in the Browser SDK reference.

  2. Prepare the SDK for install — once, on page load. This call registers the service part and attaches the app manifest:

    JavaScript
    sdk.pwa.init()
  3. Tie the install to your own button:

    HTML
    <button id="install">Install the app</button>
    <script>
    document.getElementById('install').addEventListener('click', () => {
    sdk.pwa.install()
    })
    </script>
  4. Tie the push subscription to your own button (or call it at a convenient moment):

    JavaScript
    await sdk.subscribePush()

Done — the install and subscription happen on your page. Nothing sends the visitor to the store card.

Tip

If some scenario does need the store card, sdk.showStore() opens it. Do not call this method — the visitor stays on your prelanding.

The browser shows the install

Show the install button only when install is actually available — check sdk.pwa.canInstall(). Browsers do not always allow the install prompt: a secure connection (HTTPS) is required, and usually an action by the visitor on the page. That is why both install and subscription are normally tied to an explicit tap rather than fired on load.

Verify

Open the prelanding on a phone and tap your buttons — the browser will show the install prompt and the notification prompt. The result is visible in reports: the install_accepted, push_allow and other events land in the event stream.

What's next