diff --git a/src/App.tsx b/src/App.tsx index a5af3b43..691ba2e7 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -28,6 +28,7 @@ import { DynamicFavicon } from '@/components/DynamicFavicon'; import { OfflineIndicator } from '@/components/OfflineIndicator'; import { PWAUpdatePrompt } from '@/components/PWAUpdatePrompt'; import { ErrorBoundary } from '@/components/ErrorBoundary'; +import { LockdownModeDetector } from '@/components/LockdownModeDetector'; import AppRouter from './AppRouter'; @@ -152,6 +153,7 @@ export function App() { + diff --git a/src/components/LockdownModeDetector.tsx b/src/components/LockdownModeDetector.tsx new file mode 100644 index 00000000..8ba9aaf4 --- /dev/null +++ b/src/components/LockdownModeDetector.tsx @@ -0,0 +1,73 @@ +import { useEffect, useState } from 'react'; +import { + AlertDialog, + AlertDialogContent, + AlertDialogDescription, + AlertDialogHeader, + AlertDialogTitle, +} from '@/components/ui/alert-dialog'; + +/** + * Detects if IndexedDB is unavailable (which happens in iOS lockdown mode) + * and displays a blocking alert dialog informing the user. + */ +export function LockdownModeDetector() { + const [isLockdownMode, setIsLockdownMode] = useState(false); + + useEffect(() => { + // Check if IndexedDB is available + const checkIndexedDB = async () => { + try { + // Check if IndexedDB exists + if (!window.indexedDB) { + setIsLockdownMode(true); + return; + } + + // Try to open a test database to verify IndexedDB actually works + // In iOS lockdown mode, indexedDB exists but throws errors when used + const testDBName = '_shakespeare_lockdown_test'; + const request = window.indexedDB.open(testDBName, 1); + + request.onerror = () => { + setIsLockdownMode(true); + }; + + request.onsuccess = () => { + // IndexedDB is working, clean up test database + request.result.close(); + window.indexedDB.deleteDatabase(testDBName); + }; + } catch { + // Any error means IndexedDB is not available + setIsLockdownMode(true); + } + }; + + checkIndexedDB(); + }, []); + + return ( + + + + 🔒 Lockdown Mode Detected + + + Shakespeare requires IndexedDB to function, which is unavailable in iOS Lockdown Mode. + + + To use Shakespeare, please disable Lockdown Mode in your device settings: + + + Open Settings + Go to Privacy & Security + Tap Lockdown Mode + Turn off Lockdown Mode + + + + + + ); +}
+ Shakespeare requires IndexedDB to function, which is unavailable in iOS Lockdown Mode. +
+ To use Shakespeare, please disable Lockdown Mode in your device settings: +