https://documentation.onesignal.com/docs/web-push-sdk-setup-http
Web.config
<appSettings>
<add key="OneSignalSubDomain" value="smk-demo"/>
<add key="OneSignalAppID" value="***-***-***-***-******"/>
<add key="OneSignalREST" value="****"/>
<add key="ExternalSite" value="http://hospitality.datainsighthub.com"/>
</appSettings>
View
@{
string appId = System.Configuration.ConfigurationManager.AppSettings["OneSignalAppID"];
string subdomainName = System.Configuration.ConfigurationManager.AppSettings["OneSignalSubDomain"];
}
<script src="https://cdn.onesignal.com/sdks/OneSignalSDK.js" async='async'></script>
<script>
var OneSignal = window.OneSignal || [];
OneSignal.push(["init", {
appId: "@appId",
allowLocalhostAsSecureOrigin: true,
autoRegister: true,
subdomainName: '@subdomainName',
httpPermissionRequest: {
enable: true
},
notifyButton: {
enable: true,
size: 'medium',
position: 'bottom-left',
offset: {
bottom: '30px',
left: '75px',
right: '0px'
},
preNotify: true,
showCredit: true,
text: {
'tip.state.unsubscribed': 'Awe. That hurts my feelings.',
'tip.state.subscribed': 'You are subscribed. Dont mind me chilling here.',
'tip.state.blocked': 'That hurts. Truly.',
'message.prenotify': 'Click me to stay in the loop!',
'message.action.subscribed': "Thank you for subbing true rakesh. We will keep you up to date.",
'message.action.resubscribed': "Glad to see you're back.",
'message.action.unsubscribed': "You won't receive notifications again. Promise. :(",
'dialog.main.title': 'Manage Site Notifications',
'dialog.main.button.subscribe': 'NOTIFY ME',
'dialog.main.button.unsubscribe': 'LEAVE ME ALONE',
'dialog.blocked.title': 'Unblock Notifications',
'dialog.blocked.message': "Follow these instructions to allow notifications:"
}
},
welcomeNotification: {
title: "Welcome to Notifications",
message: "Thank you for signing up for desktop notifications."
}
}])
</script>