OSX网站推送通知-从未调用过Safari requestPermission回调 [英] OSX Push Notifications for Websites - Safari requestPermission callback never called

查看:151
本文介绍了OSX网站推送通知-从未调用过Safari requestPermission回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

按照

Following the instructions as per Apple Documentation to allow a user with Safari to visit a website and get Push Notifications for the Apple Push Notification Service.

我正在使用SSL,具有Apple的证书,并且已经生成了推包文件.

I'm using SSL, have a certificate from Apple, and have generated the push package file.

Safari在运行提示符requestPermission时下载此文件,显示用户权限请求提示,但是在用户单击批准"时,永远不会调用回调函数.

Safari downloads this when running the prompt requestPermission, displays the user permission request prompt, but on the user clicking 'approve', the callback function is never called.

window.safari.pushNotification.requestPermission(url, websitePushID, userInfo, callback);

  1. 从不调用回调函数.
  2. 没有引发异常.
  3. 对于任何成功或错误,均不对服务器进行POST.
  4. 该网站现在列在系统偏好设置">通知"下.
  5. 在Safari偏好设置中的通知下,列出了该网站.
  6. 进一步请求requestPermission或查询权限的尝试被立即拒绝.
  1. The callback function is never called.
  2. No exceptions are thrown.
  3. No POST is made to the server for any success or error.
  4. The website is now listed under System Preferences > Notifications.
  5. The website is not listed under Notifications within Safari Preferences.
  6. Further attempts to requestPermission or query permission are denied instantly.

重置拒绝权限的唯一方法是在重新尝试请求之前,编辑OSX的内部sqllite文件并删除Safari中的一堆配置文件.

The only way to reset the denied permission is to edits OSXs internal sqllite file and delete a bunch of config files within Safari before I can retry the request.

是什么原因导致这种异常行为?

推荐答案

如果没有所使用的确切JavaScript很难判断,但是在Apple文档中看到的3种权限类型是默认,授予和拒绝.

It's hard to judge without the exact javascript you are using, but the 3 permission types that you see in the apple documentaion are default, granted and denied.

如果授予或拒绝该权限,则用户已经设置了是否要接收这些推送通知.一旦用户拒绝了推送通知,Apple便决定不再再次询问他们(无需更改设置.)如果已经被授予许可,则无需调用window.safari.pushNotification.requestPermission

If the permission is granted or denied, then the user has already set whether they want to receive these push notifications. Once a user has denied a push notification then Apple has made the decision that they cannot be asked again (without changing settings.) If they already have been granted permission there is no need to call window.safari.pushNotification.requestPermission

唯一一次调用window.safari.pushNotification.requestPermission的时间是既未拒绝也不授予权限.仅在这种情况下,您才需要调用该函数并期望响应以触发该回调函数.如果您看到权限请求提示,则表明requestionPermission已经起作用.

The only time that you would call window.safari.pushNotification.requestPermission is when permission has neither been denied nor granted. Only in this case will you want to call the function and expect for a response to trigger the callback function. If you see a permission request prompt it means the requestionPermission has worked.

这篇关于OSX网站推送通知-从未调用过Safari requestPermission回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆