Why this happens
iOS Safari does not implement the Web Push API that browsers like Chrome and Firefox use on desktop and Android. The Push API relies on Service Workers that can run in the background, but Apple has not enabled this capability for web apps on iPhone or iPad. As a result, a pure web application — no matter how progressive — cannot request notification permission, receive a push subscription endpoint, or display push-driven alerts when the user is not actively browsing the site.
Apple’s push architecture centers on the Apple Push Notification service (APNs). Only a native iOS app (or a macOS/Safari desktop website with a special push package) can register with APNs and receive a unique device token. That token is cryptographically tied to the app’s bundle identifier and the provisioning profile used to sign it. Without a native binary signed by your Apple Developer account, there is no token, and therefore no address to which your server can POST a notification payload.
The accepted answer on Stack Overflow summarizes the constraint: registration for push notifications “can only be performed through a native app.” Once that native app obtains the token, it sends the token to your backend. Your backend then uses the token together with your APNs authentication key (or certificate) to deliver notifications via APNs.
How to fix it
1. Build a minimal native wrapper app (most common solution)
Create a small iOS project whose only job is to load your web app in a WKWebView and handle APNs registration. This approach keeps your existing web codebase intact while satisfying Apple’s requirement for a native registration path.
Step-by-step
- Create a new Xcode project → iOS → App. Choose Swift and SwiftUI or UIKit; the wrapper logic is the same.
- Add the Push Notifications capability in the Signing & Capabilities tab. Xcode will create an entitlement file and enable the
aps-environmententitlement. - Request authorization and register early in the app lifecycle:
import UIKit
import UserNotifications
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
UNUserNotificationCenter.current().delegate = self
let center = UNUserNotificationCenter.current()
center.requestAuthorization(options: [.alert, .sound, .badge]) { granted, _ in
guard granted else { return }
DispatchQueue.main.async {
UIApplication.shared.registerForRemoteNotifications()
}
}
return true
}
func application(_ application: UIApplication,
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
let tokenString = deviceToken.map { String(format: "%02.2hhx", $0) }.joined()
// Send tokenString to your backend via HTTPS POST
sendTokenToServer(tokenString)
}
func application(_ application: UIApplication,
didFailToRegisterForRemoteNotificationsWithError error: Error) {
print("APNs registration failed: \(error)")
}
private func sendTokenToServer(_ token: String) {
// POST to your API endpoint, e.g. https://api.example.com/register-device
// Include user identifier if you have authentication
}
}
// Handle foreground presentation
extension AppDelegate: UNUserNotificationCenterDelegate {
func userNotificationCenter(_ center: UNUserNotificationCenter,
willPresent notification: UNNotification,
withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
completionHandler([.banner, .sound, .badge])
}
}
- Load your web app in a
WKWebViewthat fills the screen. If you use SwiftUI:
import SwiftUI
import WebKit
struct WebViewContainer: UIViewRepresentable {
let url: URL
func makeUIView(context: Context) -> WKWebView { WKWebView() }
func updateUIView(_ webView: WKWebView, context: Context) {
webView.load(URLRequest(url: url))
}
}
@main
struct WrapperApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
var body: some Scene {
WindowGroup { WebViewContainer(url: URL(string: "https://your-web-app.com")!) }
}
}
-
Handle deep links or custom URL schemes if your push payload should navigate to a specific route inside the web view. In
userNotificationCenter(_:didReceive:withCompletionHandler:)parse theuserInfodictionary and post aNotificationCenterevent that the SwiftUI side observes to callwebView.evaluateJavaScript("navigateTo('/path')"). -
Distribute via TestFlight or the App Store. Users install the wrapper, grant notification permission once, and thereafter receive pushes even when the app is not running.
Why this works: The wrapper is a real native binary signed by your team. It holds a valid aps-environment entitlement, so APNs issues a device token. Your server now has a valid destination for HTTP/2 requests to api.push.apple.com.
2. Use Safari Push Notifications for macOS desktop only
If a meaningful portion of your audience uses Safari on macOS, you can implement the Apple-specific web push flow documented in Configuring Safari Push Notifications. This requires:
- An Apple Developer account
- A Website Push ID registered in Certificates, Identifiers & Profiles
- A push package (JSON manifest + icons + signature) served from
/.well-known/apple-developer-merchantid-domain-associationor a custom endpoint - A JavaScript snippet that calls
window.safari.pushNotification.requestPermission()
This path does not work on iOS or iPadOS. It is a separate, desktop-only channel. If you need mobile coverage, you still need the native wrapper.
3. Fallback: non-push channels
If building and maintaining a native app is not feasible, consider these alternatives that work from a pure web context:
- Email or SMS triggered by your backend when new content arrives.
- In-app messaging (e.g., a bell icon with a badge count) that polls your API when the user has the web app open.
- Web Share Target API combined with OS-level share sheet integrations — not push, but lets users “send to self” from other apps.
None of these deliver true background push alerts on iOS, but they avoid the native wrapper requirement.
How to prevent it
- Plan for native early: If push notifications are a core feature, budget for a thin native wrapper from day one rather than retrofitting later.
- Keep the wrapper minimal: No business logic, no custom UI beyond the web view. Less code means fewer App Review rejections and easier maintenance.
- Use a cross-platform wrapper tool (Capacitor, Ionic, or a thin
WKWebViewproject) if you also target Android — Android does support Web Push, so you can share most of the web code. - Store device tokens securely: Treat APNs tokens like passwords; rotate them on app reinstall and purge them on logout.
- Monitor APNs feedback: Implement the
apns-expirationandapns-priorityheaders; handle410 Goneresponses by removing stale tokens.
FAQ
Can I use a Progressive Web App (PWA) to get push on iOS?
No. As of iOS 17, PWAs added to the Home Screen still run inside WebKit without Service Worker push event support. They can show local notifications scheduled via the Notifications API while the page is open, but they cannot receive remote push payloads when closed.
Do I need a paid Apple Developer Program membership?
Yes. The Push Notifications capability and the ability to create APNs authentication keys or certificates are only available to paid members (individual or organization). The free tier does not enable aps-environment entitlements.
What happens if the user deletes the wrapper app?
APNs will return a 410 Gone (or Unregistered) response the next time your server pushes to that token. Your backend should treat this as a signal to delete the token from its database. If the user reinstalls, a new token will be generated and sent to your server on first launch.
Summary
iOS requires a native app to register with APNs. The pragmatic fix is a lightweight WKWebView wrapper that requests notification permission, forwards the device token to your backend, and optionally deep-links into your web app when a push arrives. This satisfies Apple’s architecture while keeping your core product on the web.
Parts of this guide are adapted from content licensed under CC BY-SA 4.0; this article is shared under the same license.
