Pagina 1 din 1
Redirectionare dupa acceptare notificari prin OneSignal
Scris: Vin Ian 17, 2020
de mluci
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
Scris: Vin Ian 17, 2020
de MarPlo
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
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.
- Deci, in codul tau verifici acea valoare si faci redirect cu
window.location.
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);
});