AWS Builder Center
My Earthquake Alert App Broke on an Actual Phone Screen

My Earthquake Alert App Broke on an Actual Phone Screen

A desktop-only testing habit hid a broken mobile layout, plus the real iOS constraints on custom alert sounds in a PWA.

Series: Earthquake Alert (3 articles)

  1. 3
    My Earthquake Alert App Broke on an Actual Phone Screen This article
Cloud Engineer
Third post in this series. Through the first two posts I'd only ever tested the earthquake alert app's UI at desktop widths, around 800px. Someone asked me a simple question — "can I actually open this on my phone?" — and I realized I'd never checked it at an actual narrow viewport. I opened it at 375px and the header was broken. This post covers that fix, plus the iOS audio constraints that came up in the same conversation.

What was broken

At iPhone SE width (375px), the title wrapped onto two lines, and the language selector plus the two buttons next to it got squeezed into the remaining space so tightly that the text inside the buttons started wrapping too.
The cause was simple:
header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
}
No  flex-wrap , so the flexbox kept forcing every element onto one row regardless of available width. It never showed up in testing because every screenshot I'd taken up to that point was at desktop width, where everything fit comfortably on one line.

The fix

Added  flex-wrap: wrap  so the title and the control group fall onto their own rows when space runs out, plus  white-space: nowrap  on buttons so their text stops wrapping internally.
header {
display: flex;
align-items: center;
justify-content: space-between;
flex-wrap: wrap;
row-gap: 10px;
gap: 8px;
}

button {
white-space: nowrap;
/* ... */
}
Checked again at 375px and 390px: the title now sits on its own line, and the controls wrap cleanly underneath. The emergency card with the highlighted map held up fine too —  .japan-map svg { max-width: 100% }  was already there from the original build.

The other question: does the alert sound have iOS limitations

Same conversation, someone asked whether the custom alert sound has any constraints on iOS. It does, and they're worth writing down since they're not obvious from just using the app.
  • It only plays while the tab is open. Tapping "Enable Notifications" unlocks audio playback once via a silent play-then-pause on that user gesture, but if Safari is closed or the PWA isn't running when a push notification arrives, this custom sound will not play. iOS's Service Worker has no way to play an arbitrary audio file from a push event.
  • The unlock resets every time the page reloads. Close the tab and reopen it, and the next alert needs another tap to re-unlock audio before it can play.
  • It respects the hardware mute switch. HTML5  <audio>  on iOS is silenced by the physical silent switch, same as any other web audio.
Put together: the sound only plays when the tab is open, the phone isn't muted, and the page has been unlocked at least once since it last loaded. This is a hard limit of building this as a PWA rather than a native app — I looked at a native rewrite early on specifically for this reason and decided the sound guarantee alone wasn't worth the rebuild.


Closing thoughts

Testing only at desktop width was the actual mistake here. It's an obvious thing to check and I skipped it anyway, right up until someone asked a plain question about opening the app on their phone.

Series: Earthquake Alert (3 articles)

  1. 3
    My Earthquake Alert App Broke on an Actual Phone Screen This article
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article