Sending Push Notifications to iOS from PWA

49,640

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.

  • 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.

  • 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.

  • 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).

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.

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.

Share:
49,640
Kaan Taze
Author by

Kaan Taze

I'm mostly interested in Modern C++ and other lower languages like GoLang, C and x86 Assembly. As of August 2020, I've got my Bachelor's Degree in Computer Engineering. Currently working as a software engineer in Adana/Turkey. I like networking, multi-threading, template metaprogramming and any other mind-boggling concepts in Computer Science. I'm also interested in philosophy (Ancient Greek Philosophers, Kant, Hegel and Zizek are in my interest), history (ancient civilizations, middle age Europe and Russian history in general) and biathlon (I'm big fan of Norwegian Team)!

Updated on July 05, 2022

Comments

  • Kaan Taze
    Kaan Taze almost 2 years

    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.

    • 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?

    • 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.

  • Crates
    Crates over 3 years
    Thanks Kyle! I'm talking now with Maciej Stachowiak, head of WebKit at Apple, to see if they can expose the device ID to make Option 2 more viable. No guarantees yet, but hopefully we can see some movement on this option in 2021!
  • user1948585
    user1948585 over 3 years
    I don't understand what to do to test option 1.
  • Ayudh
    Ayudh over 3 years
    May I ask for any updates on Option 2 ? Also, is it that the push notifications don't work on iOS if the user is using Safari (meaning that they work on chrome) or that they don't work on iOS (iPhones) regardless of the browser?
  • ami solani
    ami solani about 3 years
    Can anyone please explain how to use Passkit in PWA, I don't think it's a relevant solution for PWA
  • Barbaldo
    Barbaldo about 3 years
    @Ayudh as far as I can tell (2020 iPhone SE with IOS 14), they do not work on any browser on IOS, so it's the phone, not the browser.
  • Crates
    Crates about 3 years
    @amisolani: They do work for PWAs, but they are a huge pain in the butt. We got them working for an application my current employer is using. There are several hoops to jump through and the user needs instruction on how to add the PassKit pass to their wallet. I don't especially recommend it given how much of a pain it was and how unreliable and inconsistent the notifications are. If I were you, I'd look at wrapping the app with Capacitor or Cordova.
  • Vinícius Pacheco Vieira
    Vinícius Pacheco Vieira almost 3 years
    @Crates would this API be enough to get the device ID: developer.mozilla.org/en-US/docs/Web/API/MediaDeviceInfo/…
  • ruohola
    ruohola over 2 years
    -1 How this answers the question when #1 is a hack which requires more from the user than to just install the PWA to their home screen, and #2 and #3 are not about PWAs at all, and only work for native apps?