Extended API for custom permission prompt call
New API for registerUserForPush
Opt-in (pre-subscription window) is configured in our service by the following parameters.
There are three of them at the top level:
brandingEnabled(does not change)
desktopProps
mobileProps
Within each, there are settings for positioning, color, opt-in type, and text.
It is possible to set the following types of opt-in:
- MODAL
- TOAST
- BELL
- NATIVE
The New API allows you to select a single item, or several and override them.
Example:
Gravitec.push([
"registerUserForPush",
console.log,
{ mobileProps: { type: "MODAL" }, desktopProps: { type: "MODAL" } }
]);
// The code will set the opt-in type to desktop and mobile in MODAL
Gravitec.push([
"registerUserForPush",
null,
{
desktopProps: {
subscTexts: [
{ lang: "default", value: "Overrided text for subscription prompt" }
]
}
}
]);
// The code will set the main text to the desktop opt-in.
If you need to overwrite several languages, you need to pass the whole new array.
Gravitec.push([
"registerUserForPush",
null,
{
desktopProps: {
subscTexts: [
{
lang: "default",
value: "Overrided text for subscription prompt"
},
{ lang: "en", value: "Special text for english version" },
{ lang: "ru", value: "Текст на русском" },
{ lang: "ua", value: "Текст для української версії" }
]
}
}
]);
Gravitec.push([
"registerUserForPush",
null,
{
desktopProps: {
subscTexts: [
{ lang: "en", value: "Overrided text for subscription prompt" }
],
allowTexts: [{ lang: "en", value: "Over allow" }],
blockTexts: [{ lang: "en", value: "Over block" }]
}
}
]);
// The code will set all texts for the desktop opt-in
To control opt-in call after blocking, there is a special parameter ignoreBlockedCookie, which is true by default for the registerUserForPush manual call. It ignores the cookie variable that is set after the visitor blocks on the opt-in. This variable and does not allow the subscription to be shown in the browser session.
Calling registerUserForPush manually will, by default, always show the opt-in. The cookie variable will be deleted.
The ignoreBlockedCookie parameter can be overwritten:
Gravitec.push([
"registerUserForPush",
null,
{
ignoreBlockedCookie: false,
desktopProps: {
subscTexts: [
{ lang: "default", value: "Overrided text for subscription prompt" }
]
}
}
]);