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
@@ -10,28 +10,50 @@
|
||||
"orientation": "any",
|
||||
"background_color": "#fcfbff",
|
||||
"theme_color": "#7a4cc0",
|
||||
"categories": ["travel", "navigation", "transportation"],
|
||||
"categories": [
|
||||
"travel",
|
||||
"navigation",
|
||||
"transportation"
|
||||
],
|
||||
"shortcuts": [
|
||||
{
|
||||
"name": "เช็กเวลาเดินรถ",
|
||||
"short_name": "เช็กเวลา",
|
||||
"description": "ดูตารางเวลาเดินรถทุกจุดจอด",
|
||||
"url": "/check",
|
||||
"icons": [{ "src": "/image/icons/minibus-192x192.png", "sizes": "192x192", "type": "image/png" }]
|
||||
"icons": [
|
||||
{
|
||||
"src": "/image/icons/minibus-192x192.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image/png"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "ป้ายหยุดรถ",
|
||||
"short_name": "ป้ายหยุดรถ",
|
||||
"description": "ค้นหาป้ายหยุดรถทั้งหมด",
|
||||
"url": "/stops",
|
||||
"icons": [{ "src": "/image/icons/minibus-192x192.png", "sizes": "192x192", "type": "image/png" }]
|
||||
"icons": [
|
||||
{
|
||||
"src": "/image/icons/minibus-192x192.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image/png"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "รายละเอียดสายรถ",
|
||||
"short_name": "สายรถ",
|
||||
"description": "ดูรายละเอียดเส้นทางเดินรถ",
|
||||
"url": "/routes",
|
||||
"icons": [{ "src": "/image/icons/minibus-192x192.png", "sizes": "192x192", "type": "image/png" }]
|
||||
"icons": [
|
||||
{
|
||||
"src": "/image/icons/minibus-192x192.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image/png"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"icons": [
|
||||
@@ -52,6 +74,34 @@
|
||||
"sizes": "512x512",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable"
|
||||
},
|
||||
{
|
||||
"src": "/image/icons/minibus-maskable-512x512.png",
|
||||
"sizes": "512x512",
|
||||
"type": "image/png",
|
||||
"purpose": "any"
|
||||
}
|
||||
],
|
||||
"id": "/",
|
||||
"display_override": [
|
||||
"standalone",
|
||||
"minimal-ui",
|
||||
"browser"
|
||||
],
|
||||
"prefer_related_applications": false,
|
||||
"launch_handler": {
|
||||
"client_mode": "navigate-existing"
|
||||
},
|
||||
"handle_links": "preferred",
|
||||
"scope_extensions": [],
|
||||
"edge_side_panel": {},
|
||||
"screenshots": [
|
||||
{
|
||||
"src": "/image/network/overview-map.png",
|
||||
"sizes": "1440x1080",
|
||||
"type": "image/png",
|
||||
"form_factor": "wide",
|
||||
"label": "แผนที่เครือข่ายป้าย Atroute"
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in new issue
Block a user