Add iOS Safari data persistence warning for personal-wp#3415
Add iOS Safari data persistence warning for personal-wp#3415
Conversation
Implement detection of iOS/iPadOS Safari users who haven't installed the app as a PWA, and display a dismissible warning about Safari's 7-day ITP storage wipe policy. The notice encourages users to add the app to their Home Screen for safer data persistence. - Add is-ios-safari.ts utility with isIOS, isIOSSafari, isRunningAsPWA - Add IosPwaNotice component using WordPress Notice component - Integrate notice into Layout component - Add comprehensive unit tests for iOS detection Co-authored-by: ashfame <858906+ashfame@users.noreply.github.com>
Move IosPwaNotice inside the siteView flex column so it appears as a compact banner above the browser chrome toolbar, instead of as a column beside the viewport. Co-authored-by: ashfame <858906+ashfame@users.noreply.github.com>
- Wrap localStorage.getItem and setItem in try-catch to handle private browsing mode and storage quota errors - Remove zero-width no-break space character from share icon span Co-authored-by: ashfame <858906+ashfame@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds an in-app warning banner for personal-wp users on iOS Safari to mitigate silent data loss risk from Safari’s 7‑day ITP storage purge by prompting installation as a Home Screen PWA.
Changes:
- Added iOS/iPadOS + Safari detection helpers (and unit tests) to target affected environments.
- Introduced a dismissible
IosPwaNoticethat persists dismissal inlocalStorage. - Integrated the notice into the main layout and adjusted layout CSS to support stacking above the viewport.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/playground/personal-wp/src/lib/is-ios-safari.ts | Adds iOS/Safari + PWA detection helpers used to decide when to show the warning. |
| packages/playground/personal-wp/src/lib/is-ios-safari.spec.ts | Adds Vitest coverage for iOS and iOS Safari detection logic. |
| packages/playground/personal-wp/src/components/layout/style.module.css | Updates layout to flex column so the new notice can sit above the site viewport. |
| packages/playground/personal-wp/src/components/layout/index.tsx | Renders the new IosPwaNotice within the layout. |
| packages/playground/personal-wp/src/components/ios-pwa-notice/* | Implements the warning banner UI, styling, and dismissal persistence. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| * (standalone display mode). | ||
| */ | ||
| export function isRunningAsPWA(): boolean { | ||
| return window.matchMedia('(display-mode: standalone)').matches; |
| */ | ||
| export function isRunningAsPWA(): boolean { | ||
| return window.matchMedia('(display-mode: standalone)').matches; |
| export function isIOSSafariWithoutPWA( | ||
| ua?: string, | ||
| platform?: string, | ||
| maxTouchPoints?: number | ||
| ): boolean { | ||
| return isIOSSafari(ua, platform, maxTouchPoints) && !isRunningAsPWA(); | ||
| } |
| role="img" | ||
| aria-label="share" |
| color: #1e1e1e; | ||
| font-size: inherit; | ||
| border-left-color: #dba617; |
brandonpayton
left a comment
There was a problem hiding this comment.
@ashfame thank you very much for working on this. It's important IMO since we are encouraging folks to enjoy private personal data in my.wordpress.net.
I left one comment on something that may break when the new macbook-with-touchscreen is released later this year.
Overall, I think this needs more thorough testing to make sure we cover all angles. We could test manually, but maybe the best would be to add some E2E tests for this, using Playwright device emulation. I have no idea how realistic the emulation is, but it would be worth a shot.
| ): boolean { | ||
| return ( | ||
| /iPad|iPhone|iPod/.test(ua) || | ||
| (platform === 'MacIntel' && maxTouchPoints > 1) |
There was a problem hiding this comment.
There is a Macbook supposedly coming this year that includes a touchscreen. AFAICT, that means this check will consider it as an iOS device.
|
Probably I'm missing something here. Why are we checking if it's iOS? The 7-Day cap also applies to macOS Safari if the page is not standalone. Isn't checking if it's Safari enough? |
Safari's ITP policy wipes all script-writable storage after 7 days of inactivity. Users on iOS Safari who haven't installed the app as a PWA are at risk of losing their WordPress data without warning.
Changes
src/lib/is-ios-safari.ts):isIOS,isIOSSafari,isRunningAsPWA— handles iPhone, iPad, iPadOS 13+ (reports as MacIntel), and excludes WKWebViews/CriOS/FxiOSIosPwaNoticecomponent: Dismissible warning banner using WordPressNoticecomponent, shown only to iOS Safari users not running as a standalone PWA. Dismissal persisted via localStorage (with try-catch for private browsing)Screenshot
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
cdn.cypress.io/home/REDACTED/work/_temp/ghcca-node/node/bin/node node index.js --exec install(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.