Unlike the majority of browsers, Firefox does not allow publishers to trigger the push permission prompt without a prior user gesture (version 72 and above). That user action should be a click on a webpage element (the click must not be a redirection, and scroll doesn't work as a user gesture).

If no user gesture is defined, the native behavior of the browser would be hiding the permission prompt and only displaying an icon in the search bar, thus making it hardly noticeable for website visitors:

Therefore, when integrating Batch web push, you should take into account this browser's specificity. We suggest you do that by either:

A - Defining a user gesture (or several)

That user gesture will trigger the display of the Firefox native permission prompt. This can be a click on your cookie consent request for example:

This can be done by calling the following Javascript function at the chosen event:

function displayFirefoxPermissionRequest(){ 

if(navigator.userAgent.indexOf("Firefox") !== -1) {

batchSDK(function(api){api.ui.show('native', true)});
}
}

Ideally, you should set several user gestures in order to display the opt-in request to a majority of users during their browsing.

B - Using Batch pre-permission prompts

You can also use Batch pre-permission prompts. A click on the "Accept" button will be considered as a user gesture, thereby triggering the display of the Firefox native permission request:

This is a great solution to quickly launch web push on your website.

To implement this, you would have to define a custom ui object for Firefox only (the permission request remains native for other browsers):

var batchSDKUIConfig = { native: {} 
}

if(navigator.userAgent.indexOf("Firefox") !== -1) {

batchSDKUIConfig = {

alert: { icon: 'https://mydomain.com/icon.png',
backgroundColor: '#FFFFFF',
text: 'Subscribe to our notifications!',
}
}
}

batchSDK('setup', {
...
ui: batchSDKUIConfig
});

However, we observe that the opt-in rate is not as good with this pre-permission prompt, comparing to the native prompt only. That's why you should deploy it only on Firefox, and not for other browsers which don't have the same restrictions.

We also encourage you to implement one or several custom user gestures on Firefox for a next release, as detailed in the first section of this article.

Did this answer your question?