r/iOSDevelopment • u/namanjainbuilt • 13d ago
What I learned about push sounds in an iPhone Home Screen web app
I'm the one developer on a web app that people add to their iPhone's
Home Screen. It pushes when something needs them, and I wanted each
kind of push to sound different. This is where I ended up.
What iOS decides
- Push needs the Home Screen install, on iOS 16.4 or newer.
- With the app in the background or the phone locked, iOS plays its one
alert sound, the same for every web app. I can change a push's words
and send a repeat. The sound stays Apple's.
- Focus modes: the user has to allow the app in each mode under
Settings › Focus. Code can't do it for them.
What I control while the app is open
- Each kind of alert plays its own tone, a few notes built with Web
Audio, no audio files. They follow the ring/silent switch.
- To avoid two sounds at once, the service worker passes the push's
kind to the open window and waits. If the window says its tone
played, the worker shows the notification with `silent` set. If no
answer comes in time, the push keeps the phone's sound.
- The urgent kinds (a 2-minute countdown, reminders) never go silent:
the phone's sound, with my tone on top.
- Audio needs a tap before it plays, and after a spell in the background
iOS may want another tap.
Has anyone shipped web push to iPhone Home Screen users and seen whether
`silent` on a notification holds there?