Skip to content

Add iOS Safari data persistence warning for personal-wp#3415

Open
Copilot wants to merge 4 commits intotrunkfrom
copilot/persona-wp-store-data-ios
Open

Add iOS Safari data persistence warning for personal-wp#3415
Copilot wants to merge 4 commits intotrunkfrom
copilot/persona-wp-store-data-ios

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 18, 2026

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

  • iOS/Safari detection utility (src/lib/is-ios-safari.ts): isIOS, isIOSSafari, isRunningAsPWA — handles iPhone, iPad, iPadOS 13+ (reports as MacIntel), and excludes WKWebViews/CriOS/FxiOS
  • IosPwaNotice component: Dismissible warning banner using WordPress Notice component, shown only to iOS Safari users not running as a standalone PWA. Dismissal persisted via localStorage (with try-catch for private browsing)
  • Layout integration: Notice rendered inside the site view flex column, above the browser chrome toolbar
  • 13 unit tests covering all detection scenarios (iPhone, iPad, iPadOS 13+, Chrome/Firefox on iOS, WKWebView, macOS desktop, Android, Windows)

Screenshot

iOS PWA Notice Banner

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
    • Triggering command: /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

This section details on the original issue you should resolve

<issue_title>[persona-wp] Storing data on iOS</issue_title>
<issue_description>My WordPress currently uses a Service Worker and the File System API to store user data locally.
On iOS/WebKit, Apple implements a strict Intelligent Tracking Prevention (ITP) policy. If a web app is accessed via Safari and remains inactive for 7 days, all script-writable storage is automatically cleared, resulting in complete data loss for the user.

Running the app as an installed PWA on iOS bypasses the strict 7-day browser limitation, allowing a significantly longer period to store data safely on the device. However, users are often unaware of this. If they simply use the app in Safari or leave the PWA inactive for an extended period, they remain at high risk of losing their data.

Proposed Solution
We need a multi-tiered approach to secure user data on iOS:

1. iOS User Notification & PWA Prompt

  • Implement OS detection to identify users accessing the app via iOS/iPadOS Safari.
  • Display a warning explaining the iOS background data wipe limitation.
  • Encourage users to "Add to Home Screen" (install as a PWA).

2. Remote Backups & Recovery

  • Because even PWA storage is not guaranteed permanently on iOS, we need to create a feature allowing users to perform periodic remote backups of their File System API data.
  • Target platforms: GitHub (via Gists or Repo commits), with potential future support for Google Drive, Dropbox, etc.
  • Implement a seamless "Restore" flow so users can easily recover their data online from their chosen remote storage if an OS-level wipe occurs.</issue_description>

<agent_instructions>Make sensible choices and implement the proposed solution 1 consistent with industry wide standard practices and using wordpress' own design system.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

Copilot AI and others added 3 commits March 18, 2026 16:19
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>
Copilot AI changed the title [WIP] [persona-wp] Implement iOS user notification and PWA prompt Add iOS Safari data persistence warning for personal-wp Mar 18, 2026
Copilot AI requested a review from ashfame March 18, 2026 16:27
@ashfame ashfame marked this pull request as ready for review March 19, 2026 08:37
@ashfame ashfame requested review from a team, Copilot, fellyph and zaerl March 19, 2026 08:37
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 IosPwaNotice that persists dismissal in localStorage.
  • 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;
Comment on lines +55 to +57
*/
export function isRunningAsPWA(): boolean {
return window.matchMedia('(display-mode: standalone)').matches;
Comment on lines +65 to +71
export function isIOSSafariWithoutPWA(
ua?: string,
platform?: string,
maxTouchPoints?: number
): boolean {
return isIOSSafari(ua, platform, maxTouchPoints) && !isRunningAsPWA();
}
Comment on lines +69 to +70
role="img"
aria-label="share"
Comment on lines +3 to +5
color: #1e1e1e;
font-size: inherit;
border-left-color: #dba617;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[personal-wp] Storing data on iOS

3 participants