iPhone

The iPhone app exists so EmberStorm can be on the App Store rather than only a home-screen web app (for now it is a public beta through TestFlight, not yet on the store). It is a native Swift shell around the server's own page, with songs and audiobooks played by the app's own native player - and a deliberate decision not to rewrite the app in Swift.

Three shapes, and the one chosen

Three ways of building it were weighed:

The second was chosen, built in two stages.

app.js is the whole product across five kinds of media. A Swift rewrite would mean building every feature twice from then on - and Android would still be on the web. What only native code can give on a phone is CarPlay, audio that iOS will not stop, and the lock screen: all of it audio. So only the audio goes native. Nothing commits the shell to staying thin; it can grow screen by screen later if that ever looks worth it.

The reasoning that ruled out a WebView app on Android does not carry over. Android's WebView has no Media Session API and is stopped in the background; an iPhone's WKWebView is Safari's engine, and with background audio enabled (UIBackgroundModes) and the .playback audio session, the page's <audio> keeps playing when the phone locks. That turned out not to be enough (see stage two).

Stage one: the shell

Plain Swift in ios/SoundStorm, with no Capacitor. Capacitor is built to bundle a web app inside the app, and this web app lives on each person's own server; stage two is Swift anyway. What the shell does:

Messages from the page are accepted only from the server's own origin, port included - anyone can get a *.net.emberstorm.app name, so a matching host alone is not enough.

Moving to the secure name

The first TestFlight build had a bug the Android app had had too. Opened at the away-from-home name while at home, the page moves itself to the install's home name (moveToSecureName - the server offers it to any page not already on it), and the app took that move for a link out of EmberStorm and sent it to Safari.

The app now follows a move to https on <id>.home.emberstorm.app, on the same port, where the id is the current name's own. It follows the move for this launch and does not save it. A phone leaves the house; with the home name saved, the app would stop working the moment it did. Not saving also closes a hole a security review found: from a plain-http address, anybody on the same Wi-Fi could otherwise have pinned the app to a server of their own. A move to a different name of the same install - its owner's chosen name, such as yourname.home.emberstorm.app - is followed only when both addresses' /healthz answer with the same install id - and, from a plain-http address, only when both names resolve to the same machine, since an id is only what a server says of itself.

The status bar in Now Playing

The status bar hides while Now Playing is open, and only then - the owner's choice. Android hides both bars everywhere, but an iPhone has no swipe that brings a hidden status bar back for a glance at the time, so everywhere else it stays. The app watches the page's body for the np-open class from its document-start script rather than being told by app.js, so the feature needed no change to the web app and no server deploy.

Downloads kept by the app, and opening offline

A WKWebView runs a service worker only for App-Bound Domains, and listing the two zones there would have shut the app out of every other address (a new box's plain first page, a typed IP, a Tailscale name). And iOS may clear a web view's storage - where a browser keeps downloads - when the phone is short of space or a site goes unused. So the app keeps downloads itself (KeptFiles.swift), in its own folder (Application Support/Kept/<host_port>/), which iOS never clears and which is left out of iCloud backups:

Stage two: native audio

Reported from a real iPhone: paused on the lock screen, the music could not be started again there. The page played it in the web view, and iOS suspends an app playing nothing a few seconds after a pause - the web view with it - so the lock screen's play had nothing awake to answer. So the app does what the Android app does: NativeAudio.swift, an AVQueuePlayer behind a stand-in on the page's <audio id="audio-player">, speaking the same "audio" messages as Android's, so the page needed no change.

Checked in the simulator. A real lock screen, a call or an alarm have not all been tried on a device.

Photo backup

The iPhone app backs up the camera roll to the person's own photo folder (ios/SoundStorm/PhotoBackup.swift). It answers the page's window.soundstormApp.backup(...) messages with the same status fields the Android app reports, so the page has no iPhone code: the switch and its options (Wi-Fi only, videos, only while charging) are the same Settings card.

Whose iPhone it is. A phone can back up to several servers, one account on each. On each server the first person to sign in is asked once, "Is this your iPhone?" - yes only lets them turn backup on later in Settings - and from then nobody else on that server sees a switch on that phone; the person whose phone it is can let it go (This isn't my phone). Who is signed in is asked of the server (/api/session), never taken from the page, and each server's backup sends only while its own person is signed in there. The public demo account is never asked.

Checked against a local server in the simulator: the six sample photos arrived in the right year and month, byte for byte. The background task and an upload finishing with the app closed want a real iPhone over a night.

Add media in the app asks the app for files (Photos or Files, soundstormApp.pickFiles), since a web view keeps its own picker's files to itself; the page plans and asks as ever, and the app then sends them in the same kind of background session, each to the server it was meant for. A Share extension puts EmberStorm in the system's Share sheet: what is shared is copied into a shared app-group folder, and the app hands it to the page for the same review the next time it opens (an extension may not open its app, so the sheet says to open EmberStorm).

A TV's sign-in QR code opens the app itself (Universal Links on the install's names, and soundstorm://link), but only for a server the app already knows, and the app can scan a TV's code with its own scanner; a code that came by a link is typed, never accepted unseen. While the phone controls a TV, its volume buttons turn the TV's volume.

Several saved servers

A phone may know several servers - their own, and a relative's elsewhere. The connect screen is Your servers: the latest used first, the one in use ticked, a tap to switch, a hold for Rename and Remove, and a way to add another. The list (ServerAddress.all, in ios/Shared and used by the Apple TV app too) keeps each address and a name; a first name is the address without .home.emberstorm.app. Sign-ins stay with each server, since cookies belong to an address, so switching signs nobody out.

How it is tested

An XCUITest in ios/SoundStormUITests drives the app through connecting and signing in, and skips itself when no server answers locally. simctl cannot type or tap, and scripting the Simulator through System Events waits on a macOS permission prompt nobody sees, so the UI test is how the app gets driven. Two small traps from building it: a centred stack view measures a multi-line label as one line until preferredMaxLayoutWidth is set, and in the UI test the keyboard's accessory bar sits over the web form's submit button, so the test presses Return instead - which is also what a person does.

The iPhone and Apple TV apps share one bundle id, so Apple's Universal Purchase will make them a single App Store listing (see TVs).