Add service worker and harden the web app manifest for Android 14+ / iOS 17+
Android (Samsung S23, One UI 6) refuses 'Install app' / standalone mode when the origin is not secure or the app has no service worker. The ported Next.js app shipped neither: only a manifest existed, and no sw.js at all. - public/sw.js: navigation network-first with an offline fallback, cache-first for static assets, /api and /files bypassed, versioned cache with skipWaiting + clients.claim. - public/offline.html: offline shell. - src/components/PwaBoot.tsx: registers the worker, wires beforeinstallprompt into an in-app install button, and shows a share-sheet hint on iOS/Samsung Internet where the event never fires. - ui-manifest.json: add id, display_override, prefer_related_applications, launch_handler, handle_links, a maskable icon for Android 14 and screenshots for the install preview. - layout.tsx: viewport-fit=cover, interactive-widget, maximumScale 5 (never user-scalable=no), appleWebApp metadata, format detection off, and drop manually duplicated meta tags that Next already emits. Verified: manifest passes 8/8 installability checks, sw.js and offline.html serve with correct content types, tsc clean, npm run build passes.
This commit is contained in:
1 parent
3519f92669
commit
092f551b7d
7 files changed
+405
-11
No files matched your search
@@ -0,0 +1,47 @@
|
||||
<!doctype html>
|
||||
<html lang="th">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
|
||||
<title>ออฟไลน์ | Atroute</title>
|
||||
<link rel="stylesheet" href="/vendor/fonts/k2d.css" />
|
||||
<style>
|
||||
:root { color-scheme: light; }
|
||||
* { box-sizing: border-box; }
|
||||
body {
|
||||
margin: 0;
|
||||
min-height: 100dvh;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
padding: 24px;
|
||||
background: #fcfbff;
|
||||
color: #2c2340;
|
||||
font-family: "K2D", "Noto Sans Thai", system-ui, sans-serif;
|
||||
text-align: center;
|
||||
}
|
||||
.box { max-width: 360px; }
|
||||
img { width: 72px; height: 72px; object-fit: contain; margin-bottom: 18px; }
|
||||
h1 { font-size: 1.25rem; margin: 0 0 8px; }
|
||||
p { margin: 0 0 20px; color: #6f6a80; line-height: 1.6; font-size: 0.95rem; }
|
||||
button {
|
||||
min-height: 44px;
|
||||
padding: 10px 22px;
|
||||
border: 0;
|
||||
border-radius: 999px;
|
||||
background: #7a4cc0;
|
||||
color: #fff;
|
||||
font: inherit;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="box">
|
||||
<img src="/image/icons/minibus-512x512.png" alt="" />
|
||||
<h1>ไม่มีการเชื่อมต่อ</h1>
|
||||
<p>หน้านี้ต้องใช้อินเทอร์เน็ต — หน้ำที่เคยเปิดไว้จะยังใช้งานได้ตอนออฟไลน์</p>
|
||||
<button type="button" onclick="location.reload()">ลองอีกครั้ง</button>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user