从PWA发送推送通知到iOS [英] Sending Push Notifications to iOS from PWA

查看:66
本文介绍了从PWA发送推送通知到iOS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对不起,我知道之前已经有人问过这个问题,但是我找不到更新的答案.

I'm sorry, I know this question has been asked before but I couldn't find updated answer.

我有一个使用Blazor WebAssembly制作的Progressive Web App,我想知道是否可以将推送通知发送到iOS设备?尽管人们说现在可以在MacOS上的Safari上运行,但是Push API的网站上说它不支持iOS上的Safari.

I've got a Progressive Web App which made with Blazor WebAssembly and I was wondering if I can send push notifications to iOS devices? Although people said if works now on Safari on MacOS, Push API's website says that it does not support Safari on iOS.

  • 如果我定位到iOS,是否需要包装每个Web应用程序?我没有MacBook,是否需要购买一台MacBook?

  • Do I need to wrap every web app if I target iOS? I don't have a MacBook, do I need to buy one just to achieve this?

还有Firebase和Azure通知中心,我是否可以仅使用它们的服务为iOS发送通知?Firebase仅具有Objective-C和Swift示例.

Also there are Firebase and Azure Notification Hub, Can't I just use their service to send notifications for iOS? Firebase's had only Objective-C and Swift examples.

这还引发了另一个问题:通知的传输方式是否取决于平台?我对云服务在此上的作用感到困惑.

This also led to another question: Are notifications' way of transport is platform depended? I'm confused with cloud services' role on this.

如果有人能清除我头上的雾气,我将不胜感激.

I'd appreciate if someone can clear the fog in my head on this.

推荐答案

您只有三个主要选项来获取在PWA的iOS上运行的推送通知.在这两种情况下,您都必须在Apple Developer门户上注册一个应用程序ID,并获得相应服务的许可.对于选项1,您注册的App ID必须具有Apple Wallet的许可.对于选项2和3,您必须具有推送通知"权限.在这两种情况下,您都应记录您的Bundle ID和Team ID,以备日后使用.

You have only three main options to get push notifications working on iOS for a PWA. In both cases, you must register an App ID on Apple Developer portal, with permission to the appropriate service. For Option 1, your registered App ID must have permission to Apple Wallet. For options 2 and 3, you must have permission to Push Notifications. In both cases, you should record your Bundle ID and Team ID in case you need it later.

  • 选项1(更简单):使用PassKit设置通用的Apple Wallet通行证,该通行证可以代理与本机通知非常相似的通知.这里 一些

  • Option 1 (Easier): Use PassKit to set up a generic Apple Wallet pass, which can broker notifications that are very similar to native ones. Here's some documentation, and here's a working demo of how this can send push notifications to registered devices.

选项2(更复杂):使用 Firebase云消息传递或类似 Node-APN 之类的包发送推送通知适当";方式,使用Apple Developer Portal中的P12或P8密钥签名.这变得棘手,主要是因为您需要iOS设备标识符,该标识符仅对本机安装的应用程序公开.恐怕我没有关于如何从PWA中获取此设备ID的答案,如果没有它,此方法将不起作用.

Option 2 (Harder): Use Firebase Cloud Messaging or a package like Node-APN to send push notifications the "proper" way, signed with a P12 or P8 key from the Apple Developer Portal. This gets tricky mainly because you need the iOS device identifier, which is only exposed to applications installed natively. I'm afraid I don't have an answer on how to get this device ID from within a PWA, and without it, this method doesn't work.

选项3(不是PWA):您可以将App ID与预配配置文件和P12或P8密钥一起使用,类似于上一个选项,但是将应用程序包装在

Option 3 (not a PWA): You can use an App ID with a provisioning profile and either a P12 or P8 key, similar to the previous option, but you wrap your application in Apache Cordova, and distribute it (either through the public app store, or using MDM software and via the private Apple Business Manager).

这些是您的选择.我已经竭尽全力研究此问题,并且我相信至少在接下来的几个月中,这些仍然是您唯一的选择.我们可能会在将来看到对Web Push的进一步支持,或者也许只是将来从Web上获取设备ID的一种方式,但是直到那时,仅此而已.目前没有其他方法可以解决这个问题.

Those are your options. I have exhausted every possible avenue researching this, and I am confident that these will remain your only options through at least the next several months. It's possible we may see further support for Web Push or perhaps just a way to get the device ID from the web in the future, but until that time, this is it. There aren't any other ways to go about this presently.

资料来源:我为Subway,Gartner,Morgan Stanley和PwC(以及其他许多公司)等主要品牌设计和开发应用程序.我的研究是最近的,包括与Apple WebKit负责人以及世界上最重要的PWA和iOS专家之一进行直接交流.

Source: I architect and develop apps for major brands like Subway, Gartner, Morgan Stanley and PwC (among many others). My research is very recent, and includes direct communication with the head of WebKit at Apple, and also with one of the world's foremost PWA and iOS experts.

这篇关于从PWA发送推送通知到iOS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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