英文:
Does ios 16.5 support Web Push API from firebase?
问题
根据这个页面,PUSH API 将从 iOS 16 开始受支持。
https://webkit.org/blog/12945/meet-web-push/
根据这个页面,iOS 16.4 和 16.5 部分支持。
https://caniuse.com/push-api
注意:通知权限已成功允许
现在我已经使用了这个函数来测试我的手机是否支持 Web Push:
function WebPushSupported() {
if (!window.Notification) {
return false;
}
if (!('serviceWorker' in navigator)) {
return false;
}
if (!('PushManager' in window)) {
return false;
}
return true;
}
现在我已经在我的 iOS 16.5(13 pro max)上进行了测试
结果如下:
- 对于 Safari 浏览器:返回 false
- 对于 PWA 应用程序:返回 true
因此,在 PWA 应用程序上,我可以正常获取令牌,并且当我尝试使用该令牌发送消息时,在结果中我收到了消息 ID,但我仍然无法在 PWA 应用程序上收到通知。
这是我的测试请求的截图:
请问您是否可以告诉我在 iOS PWA 上是否支持推送 API?如果是的话,我是否遗漏了一些步骤或设置来使 PWA 应用程序生效?
英文:
According to this page PUSH API will be supported from ios 16.
https://webkit.org/blog/12945/meet-web-push/
And According to this page ios 16.4 and 16.5 are partial support.
https://caniuse.com/push-api
Noted: Notification Permission has been allowed successfully
Now I've used this function to test if my phone is support Web Push or not
function WebPushSupported()
{ if (!window.Notification)
{ return false;
}
if (!('serviceWorker' in navigator))
{ return false;
}
if (!('PushManager' in window))
{ return false;
}
return true;
}
Now I've test on my ios 16.5 (13 pro max)
The result :
- For safari browswer : return false
- For PWA app : Return true
So on PWA app I can get token normally and when I try to use that token to send message then on results I got the message_id , but I still could not get notification on PWA app.
Here is my test request
Could you guy tell me Does push API is supported on ios PWA or not? If yes Do I miss some flows or settings for PWA app?
答案1
得分: 2
我也在为此苦恼。我已阅读,您必须按照以下步骤操作:
- 打开Safari设置 --> 实验性功能 --> 推送API
然后,
- 在Safari中打开您想要授权的网站
- 分享 --> 添加到主屏幕
- 然后从主屏幕打开应用程序
- 单击您应用程序的按钮以订阅推送
- 接受
当用户从主屏幕移除应用程序时,权限会自动撤销。
英文:
I'm struggling with this too. I've read you must follow these steps:
- Open Safari settings --> Experimental Features --> Push API
then,
- Open the website your want permissions for in Safari
- Share --> Add to Homescreen
- Then open the app from your homescreen
- Click your app's button to subscribe to push
- Accept
When the user removes the app from the homescreen the permission is automatically revoked
答案2
得分: 0
是的,在iOS PWA中支持使用FCM进行Web推送。我已经在我的PWA中使它们正常工作。
您是否已经实现了一个服务工作线程来处理推送通知?
- 我建议使用Google Worbox作为服务工作线程的核心。
- 参考此指南来集成FCM。
注意:服务工作线程很复杂,您需要投入一些合理的努力来确保它正常工作...
英文:
Yes, web push using FCM are supported in ios PWA. I have them working in my PWA.
Have you implemented a service worker to process the push notifications?
- I suggest using Google Worbox for the core of the service worker
- Follow this guide to integrate FCM
Note: service worker are complex, and you will want to allocate some reasonable effort to get it properly working...
答案3
得分: -2
我没有足够的声望来点赞 @SuperSecretAndNotSafeFromWork 的回答。但我可以告诉您,这对我来说是解决方法。
我已经阅读了大量的论坛帖子,并在实验性功能中启用了 Push API,然后从 Safari 浏览器重新下载应用程序,将其作为书签,通知就像预期的那样与 FCM 一起正常工作了!
从 Firebase 控制台中的 FCM 云测试消息 UI 进行了测试。这是在 iOS 16.4.1 上的情况。感谢 SuperSecretAndNotSafeFromWork 的回答
更新:截至 16.5(新手机),启用推送 API 不再必要,它可以立即正常工作。
英文:
I dont have the rep to upvote @SuperSecretAndNotSafeFromWork answer. But I can tell this was the solution for me.
I've been reading tons of forums and going into the experimental Features -> enable Push API then redownloading the application as a bookmark from Safari browser made the notifications works as expected with FCM!
Tested from FCM cloud test message UI in the firebase console. This is on iOS 16.4.1. Thank SuperSecretAndNotSafeFromWork for the answer
UPDATE: as of 16.5 (new phone) enable push API wasn't nessesary and it did work out of the box
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论