Last active
January 6, 2017 14:15
-
-
Save heanfig/60d0f9d1ca1074e3bb82d6ee4cac9e3d to your computer and use it in GitHub Desktop.
Configure One Signal Any website see : https://documentation.onesignal.com/docs/customize-permission-messages
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://cdn.onesignal.com/sdks/OneSignalSDK.js" data-source="mautic"></script> | |
<script data-source="mautic"> | |
var OneSignal = OneSignal || []; | |
OneSignal.push(["init", { | |
appId: "27787d27-d2fd-4492-9265-580124367491", | |
safari_web_id: "", | |
subdomainName: 'https://inboundfelicident.onesignal.com', | |
autoRegister: true, | |
notifyButton: { | |
position: 'bottom-left', | |
enable: true, | |
text: { | |
'tip.state.unsubscribed': 'Subscribirse a las notificaciones', | |
'tip.state.subscribed': "Ya estas suscrito a las notificaciones", | |
'tip.state.blocked': "Tines bloqueado las notificaciones", | |
'message.prenotify': 'Clic para suscribirse a las notificaciones', | |
'message.action.subscribed': "Gracias Por Suscribirte!", | |
'message.action.resubscribed': "Ya estas suscrito a las notificaciones", | |
'message.action.unsubscribed': "No vas a recibir notificaciones", | |
'dialog.main.title': 'Manage Site Notifications', | |
'dialog.main.button.subscribe': 'SUSCRIBIRSE', | |
'dialog.main.button.unsubscribe': 'CANCELAR SUSCRIPCIÓN', | |
'dialog.blocked.title': 'Desbloquear notificaciones', | |
'dialog.blocked.message': "Sigue las instrucciones para Permitir las notificaciones:" | |
} | |
}, | |
promptOptions: { | |
/* These prompt options values configure both the HTTP prompt and the HTTP popup. */ | |
/* actionMessage limited to 90 characters */ | |
actionMessage: "Nos gustaría mostrarle las últimas noticias y actualizaciones.", | |
/* acceptButtonText limited to 15 characters */ | |
acceptButtonText: "ME INTERESA", | |
/* cancelButtonText limited to 15 characters */ | |
cancelButtonText: "NO GRACIAS", | |
/* Sitename */ | |
siteName: 'Felicident', | |
/* Example notification title */ | |
exampleNotificationTitle: 'Contamos con un nuevo servicio', | |
/* Example notification message */ | |
exampleNotificationMessage: 'Disponible en las tiendas', | |
/* Text below example notification, limited to 50 characters */ | |
exampleNotificationCaption: 'Puedes desuscribirte en cualquier momento', | |
} | |
}]); | |
var postUserIdToMautic = function(userId) { | |
var xhr = new XMLHttpRequest(); | |
xhr.open('post', 'http://98.142.105.122/~inboundfeliciden/notification/subscribe', true); | |
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); | |
xhr.send('osid=' + userId); | |
}; | |
OneSignal.getUserId(function(userId) { | |
if (! userId) { | |
OneSignal.on('subscriptionChange', function(isSubscribed) { | |
if (isSubscribed) { | |
OneSignal.getUserId(function(newUserId) { | |
postUserIdToMautic(newUserId); | |
}); | |
} | |
}); | |
} else { | |
postUserIdToMautic(userId); | |
} | |
}); | |
// Just to be sure we've grabbed the ID | |
window.onbeforeunload = function() { | |
OneSignal.getUserId(function(userId) { | |
if (userId) { | |
postUserIdToMautic(userId); | |
} | |
}); | |
}; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment