How to ask the browser notification permission directly

how-to
web
tech

#1

You prefer to ask the browser notification permission directly instead of using our default optin dialog.

Important note: Asking the user for permission on page load is being deprecated by Google Chrome in favor of asking for permission in response to a user click.

Tip: You can customize our default optin dialog stylesheet and integrate it seamlessly within your website. You can also disable it entirely and do your own UI which will trigger the user permission prompt. This is the best way to go.

First of all, you need a paid plan and use your own custom HTTPS domain, as sticking with a .by.wonderpush.com domain requires the use of a popup anyway.
Don’t forget to host the 2 required files and update the custom domain in the dashboard. Use the exact full domain most of your users browse.

Then you will need to disable the default optin-dialog plugin and use the optin-automatic one instead:

WonderPush.init({
    webKey: YOUR_WEBKEY_HERE,
    // [...]
    plugins: {
        'optin-dialog': null, // Disable the default optin-dialog plugin
        'optin-automatic': { // Enable the direct permission prompt plugin
            triggers: {
                // To ask immediately, leave blank (that is use `triggers: {}`)
                // To ask after 3 pages, use the following line only:
                minPages: 3,
                // To ask after 2 visits, use the following line only:
                minVisits: 2,
            }
        }
    }
});

Remember that this behavior is deprecated and will likely break with a future release of Google Chrome, other major browsers may follow.


Notification popup for wonderpush
#2