Reputation: 4644
I am setting up web push notification with OneSignal by reading their documentation. The follwoing code block is my configuration example
<script>
var OneSignal = window.OneSignal || [];
OneSignal.push(["init", {
appId: "my-app-id",
safari_web_id: 'my-safari-web-id',
autoRegister: false,
notifyButton: {
enable: true /* Set to false to hide */
},
}]);
</script>
It work on Google Chrome vs Firefox. But does not work on safari and when I click on Subscribe to notifications button I got the error like the following
What's wrong on my configuration?
I use safari Version 10.0.1 (12602.2.14.0.7)
Upvotes: 5
Views: 11207
Reputation: 21
You can use OneSignal.log.setLevel('trace'); to trace your problem. It may tell you exact problem like icon is missing or p12 is wrong.
Upvotes: 2
Reputation: 41
Here are some of the reasons why this might be happening on Safari. From https://github.com/OneSignal/OneSignal-Website-SDK/wiki/Safari-Registration-Bug:
Ordered by most likely to least likely:
The Safari Site URL's origin must match the origin in your address bar. Even if your hosts file allows for an alias, you must use the actual origin listed in the Site URL when subscribing. The Site URL is even case-sensitive.
The safari_web_id parameter must match the Safari Web ID in the app's platform settings. Make sure it isn't being overridden by another value, or that the web.onesignal.auto prefix wasn't missed if they're using our autogenerated certificate.
The icon must be square (width equal to height).
Make sure you're not browsing Safari in a Private window.
Make sure you're not using Safari on iOS. Safari on Windows is not supported. Some users might download Safari 5.1.7 to test out push notifications, but the only Safari that is supported is Safari 7.1+ on the Mac OS X operating system.
The icon's DPI must be 72x72.
This can be checked using ImageMagick, with the command identify -format "%w x %h %x x %y" PATH_TO_FILE.
If a custom certificate is used, it may be invalid. Recreate the Safari platform using an auto-generated certificate. Contact OneSignal for this.
Finally, the auto-generated certificate may not be working correctly. Recreate the Safari platform using another auto-generated certificate. Contact OneSignal for this.
Upvotes: 4
Reputation: 8271
Try to Paste the following Code in your Console and Check for the Error what you are getting
window.safari.pushNotification.requestPermission(OneSignal._API_URL + 'safari', OneSignal.config.safari_web_id, {app_id: OneSignal.config.appId}, function(response) {
console.warn('pushNotification.requestPermission Safari Registration Result:', response);
});
If in your Console it says Push Notification Prompt Has been disabled Follow the below steps
Upvotes: 0