Created
May 3, 2023 19:34
-
-
Save italopinto/889371f64be744e2a263da590044c1b9 to your computer and use it in GitHub Desktop.
OneSignal custom code implementation example
This file contains hidden or 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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<meta name="description" content=""> | |
<meta name="author" content=""> | |
<link rel="icon" type="image/png" sizes="16x16" href="assets/images/favicon.png"> | |
<title>Home</title> | |
<!-- IMPORTAR ESSAS DUAS LINHAS NAS DEMAIS PAGINAS HTML --> | |
<!-- BAIXAR OS ARQUIVOS JAVASCRIPT DO ONESIGNAL --> | |
<script src="https://cdn.onesignal.com/sdks/OneSignalSDK.js" defer></script> | |
<script src="/dist/js/onesignal-init.js"></script> | |
</head> | |
<body> | |
</body> | |
</html> |
This file contains hidden or 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
window.OneSignal = window.OneSignal || []; | |
OneSignal.push(function() { | |
OneSignal.init({ | |
appId: "<your app id>", | |
safari_web_id: "<your safari web id>", | |
promptOptions: { | |
slidedown: { | |
prompts: [ | |
{ | |
type: "push", | |
autoPrompt: true, | |
text: { | |
/* limited to 90 characters */ | |
actionMessage: "Quer saber mais sobre o que fazemos?.", | |
/* acceptButton limited to 15 characters */ | |
acceptButton: "Permitir", | |
/* cancelButton limited to 15 characters */ | |
cancelButton: "Cancelar" | |
}, | |
} | |
] | |
} | |
}, | |
notifyButton: { | |
enable: true, | |
text: { | |
'tip.state.unsubscribed': 'Inscreva-se para notificações', | |
'tip.state.subscribed': "Você está inscrito para notificações", | |
'tip.state.blocked': "Você bloqueou as notificações", | |
'message.prenotify': 'Click to Inscreva-se para notificações', | |
'message.action.subscribed': "Thanks for subscribing!", | |
'message.action.resubscribed': "Você está inscrito para notificações", | |
'message.action.unsubscribed': "Você não receberá mais notificações", | |
'dialog.main.title': 'Gerenciar as notificações do site', | |
'dialog.main.button.subscribe': 'INSCREVA-SE', | |
'dialog.main.button.unsubscribe': 'CANCELAR SUBSCRIÇÃO', | |
'dialog.blocked.title': 'Desbloquear as notificações', | |
'dialog.blocked.message': "Siga essas instruções para permitir as notificações:" | |
}, | |
colors: { | |
'circle.background': 'rgb(191, 221, 113)', | |
'circle.foreground': 'black', | |
'badge.background': 'rgb(191, 221, 113)', | |
'badge.foreground': 'black', | |
'badge.bordercolor': 'black', | |
'pulse.color': 'black', | |
'dialog.button.background.hovering': 'rgb(77, 101, 113)', | |
'dialog.button.background.active': 'rgb(70, 92, 103)', | |
'dialog.button.background': 'rgb(191, 221, 113)', | |
'dialog.button.foreground': 'black' | |
}, | |
}, | |
autoResubscribe: true, | |
allowLocalhostAsSecureOrigin: true, | |
notificationClickHandlerMatch: "origin", | |
notificationClickHandlerAction: "focus", | |
persistNotification: false, | |
welcomeNotification: { | |
"title": "Bem-vindo!", | |
"message": "Obrigado por se subscrever!", | |
// "url": "" | |
} | |
}); | |
OneSignal.showSlidedownPrompt(); | |
OneSignal.SERVICE_WORKER_PARAM = { scope: '/push/onesignal/' }; | |
OneSignal.SERVICE_WORKER_PATH = 'push/onesignal/OneSignalSDKWorker.js'; | |
OneSignal.SERVICE_WORKER_UPDATER_PATH = 'push/onesignal/OneSignalSDKUpdaterWorker.js'; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tem que atualizar para a versão estável, mais recente.