I am getting this error when I am trying to subscribe someone to notifications on localhost with xampp (with a custom domain: servercode.com
):
window.OneSignal already defined as ‘object’!
Please make sure to define as 'window.OneSignal = window.OneSignal || ;
And I am also getting another error saying:
Installing service worker failed SecurityError: Failed to register a ServiceWorker for scope (https://servercode.com/
) with script (https://servercode.com/OneSignalSDKWorker.js?appId=48a8ea77-2f42-4f54-8f4f-f21f0e3d9b3b
): An SSL certificate error occurred when fetching the script.
Here is my js code:
window.OneSignal = window.OneSignal || [];
OneSignal.push(function() {
OneSignal.init({
appId: "key",
notifyButton: {
enable: true,
},
promptOptions: {
slidedown: {
enabled: true,
autoPrompt: true,
timeDelay: 20,
pageViews: 3,
actionMessage: "We'd like to show you notifications for the latest news and updates.",
acceptButtonText: "ALLOW",
cancelButtonText: "BLOCK",
}
}
});
});
And I did remember to put in:
<script src="https://cdn.onesignal.com/sdks/OneSignalSDK.js" async=""></script>
Can you help me?