Question:
Would like to set up so that if permission request accepted - redirect a user to one sub-domain. If denied then to another sub-domain
Answer:
Use the Web SDK's addEventHandler API. The permission-granted and permission-denied events fire both when the user resolves the native prompt and during SDK initialization if the permission state is already known, so one snippet covers both a fresh decision and an already-given permission:
(function () {
var deniedLocation = 'https://google.com';
var successLocation = 'https://facebook.com';
Pushwoosh.push(['onLoad', function (api) {
Pushwoosh.addEventHandler('permission-granted', function () {
window.location = successLocation;
});
Pushwoosh.addEventHandler('permission-denied', function () {
window.location = deniedLocation;
});
}]);
})();The older Pushwoosh.push(['onSubscribe', ...]) / onPermissionDenied callbacks and the Pushwoosh.permissionOnInit property are not part of the current Web Push SDK 3.0 event API and should not be relied on; use addEventHandler as shown above.
Comments
0 comments
Please sign in to leave a comment.