Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Check

Checking Web Push supportability

Method Objective

The method allows checking if Web Push is available in the browser.

Warning

Web Push Notifications don't work in incognito mode. The method will give a false result when the browser is in that mode.

Syntax and parameters

Code Block
languagejs
themeFadeToGrey
personaclick("subscription", "web_push_supported", callback);

NameTypeRequirementDescription
callbackfunctionFunctionrequiredIt's a The callback function that takes a boolean value of the check result as a parameterthe API response. The API response type is a boolean.

API response

Type
ValueTypeDescription
booleanThe result of checking Web Push supportboolean

Example of use

Code Block
languagejs
themeFadeToGrey
personaclick("subscription", "web_push_supported", function(supported) {
    if (supported) {
        // if Web Push is supported
    } else {
        // if Web Push isn't supported
    }
});



Checking

a user's subscription

permission status

Method Objective

The method checks if the user has permitted to show Web Push notifications.

Syntax and parameters

Code Block
languagejs
themeFadeToGrey
personaclick("subscription", "web_push_subscribed", callback);

NameTypeRequirementDescription
callback
function
Functionrequired
It's a
The callback function that takes
a boolean value of the check result as a parameter
the API response. The API response type is a boolean.

API response

Typeboolean
TypeValueDescription
booleanThe result of the permission check

Example of use

Code Block
languagejs
themeFadeToGrey
personaclick("subscription", "web_push_subscribed", function(subscibed) {
    if (subscibed) {
        // if the user has permitted Web Push notifications
    } else {
        // if the user hasn't yet permitted Web Push notifications or has rejected the request
    }
});
Subscribing a

Getting user permission

Method Objective

The method allows subscribing the user to Web Push notifications using only the system permissions window in the browser.

Tip

We recommend using the Programmatic Pop-Ups tool for more flexibility in configuring the user's subscription to Web Push notifications.

Syntax and parameters

Code Block
languagejs
themeFadeToGrey
personaclick("subscription", "web_push_subscribe", callback);

NameTypeRequirementDescription
callback
function
Functionrequired
It's a
The callback function that takes
a boolean value of the user's subscription result
the API response. The API response type is a boolean.

API response

Value
TypeDescription
Type
booleanThe result of subscription
boolean

Example of use

Code Block
languagejs
themeFadeToGrey
personaclick("subscription", "web_push_subscribe", function(subscibed) {
    if (subscibed) {
        // if the user has subscribed to Web Push notifications
    } else {
        // if the user rejects the Web Push notification subscription
    }
});



Column

Page Navigation

Table of Contents
maxLevel2

classpersonaclick-fixed-position

indent0px
stylenone




Related Pages

Filter by label (Content by label)
showLabelsfalse
showSpacefalse
sorttitle
cqllabel in ("webpush","notifications")