Buna ziua, am site-ul today-news.eu
As vrea ca dupa ce utilizatorul accepta notificarile primite prin Onesignal sa il redirectionez spre o pagina de bun venit.
Aveti idee cum pot face asta?
Redirectionare dupa acceptare notificari prin OneSignal
-
- Mesaje:31
Redirectionare dupa acceptare notificari prin OneSignal
MarPlo
Mesaje:4343
Salut,
Vezi ce afiseaza in consola la clic pe Allow /Accept.
In documentatia de la:
documentation.onesignal.com/docs/web-push-sdk#section-notification-permission-change
spune asa pentru valoarea returnata de: permissionChange.to
- Deci, in codul tau verifici acea valoare si faci redirect cu window.location.
Incearca asa:
Vezi ce afiseaza in consola la clic pe Allow /Accept.
In documentatia de la:
documentation.onesignal.com/docs/web-push-sdk#section-notification-permission-change
spune asa pentru valoarea returnata de: permissionChange.to
Cod: Selectaţi tot
If to is "granted", the user has allowed notifications.
If to is "denied", the user has blocked notifications.
If to is "default", the user has clicked the 'X' button to dismiss the prompt.
Incearca asa:
Cod: Selectaţi tot
OneSignal.on('notificationPermissionChange', function(permissionChange){
var currentPermission = permissionChange.to;
if(currentPermission =='granted'){
window.location.href ='https://marplo.net'; //pagina pt. redirect
return;
}
console.log('New permission state:', currentPermission);
});