Web Push for iOS Home Screen apps
Enable Web Push in an iPhone Home Screen web app by preparing its service worker and subscribing on a tap.
If your push code works on desktop, open the site as a Home Screen web app to try it on an iPhone. iOS and iPadOS 16.4 added Web Push for these apps.
On iPhone and iPad, the Push API requires the Home Screen web app. Serve the site over HTTPS and prepare its service worker before offering a subscribe button.
Open the site as a Home Screen app
On iOS and iPadOS 16.4 through 18, use "display": "standalone" or "fullscreen" in the manifest to open the site as an app. Link the file with <link rel="manifest" href="/manifest.webmanifest">.
{
"name": "Pushy",
"short_name": "Pushy",
"start_url": "/",
"display": "standalone",
"icons": [{ "src": "/icon-192.png", "sizes": "192x192", "type": "image/png" }]
}In Safari, choose Share, then Add to Home Screen, and open the new icon. In iOS and iPadOS 26, leave Open as Web App enabled. Version 26 can open any added site this way, and a manifest still supplies the name and icons.
Check before you ask
Start with a hidden <button id="enable-push" type="button" hidden>Enable notifications</button> and a <p id="message" role="status"></p>. Run the script as a module after the elements exist. Set vapidPublicKey to the base64url public key from your push server.
// Import the public key that matches the private key on your server.
import { vapidPublicKey } from './push-config.js'
function urlBase64ToUint8Array(base64) {
const padding = '='.repeat((4 - (base64.length % 4)) % 4)
const raw = atob((base64 + padding).replace(/-/g, '+').replace(/_/g, '/'))
return Uint8Array.from(raw, (char) => char.charCodeAt(0))
}
const button = document.querySelector('#enable-push')
const message = document.querySelector('#message')
if ('serviceWorker' in navigator && 'PushManager' in window) {
try {
await navigator.serviceWorker.register('/sw.js')
const registration = await navigator.serviceWorker.ready
const applicationServerKey = urlBase64ToUint8Array(vapidPublicKey)
button.addEventListener('click', async () => {
button.disabled = true
try {
const subscription = await registration.pushManager.subscribe({
userVisibleOnly: true,
applicationServerKey,
})
const response = await fetch('/api/push', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify(subscription),
})
if (!response.ok) throw new Error('Could not store the subscription')
message.textContent = 'Notifications enabled.'
button.hidden = true
} catch (error) {
message.textContent = error.name === 'NotAllowedError'
? 'Check your notification permissions.'
: 'Could not enable notifications.'
} finally {
button.disabled = false
}
})
button.hidden = false
} catch {
message.textContent = 'Could not prepare the service worker.'
}
} else if (navigator.standalone === false) {
message.textContent = 'On iOS 16.4 or later, open this site from your Home Screen as a web app.'
} else {
message.textContent = 'Web Push is unavailable here.'
}The install message uses navigator.standalone as a hint. The button depends on the Push API and an active service worker. It calls subscribe() directly from the tap so the browser can prompt for permission.
The example decodes the VAPID public key to bytes. Create /api/push on your server to store the subscription and use the matching private key when sending a push.
Show the notification
The service worker receives the push and has to show something, since userVisibleOnly: true promises that every push is visible.
// sw.js
self.addEventListener('push', (event) => {
const data = event.data ? event.data.json() : { title: 'Pushy', body: 'Hello' }
event.waitUntil(self.registration.showNotification(data.title, { body: data.body }))
})Send a JSON payload with title and body to try the worker. Then test the full flow on an iPhone or iPad, where a desktop permission prompt cannot confirm the Home Screen requirement.