A Progressive Web App uses web technologies but can be installed and run across supported devices with an app-like experience. This guide converts a Cocos Creator Web Mobile build into a PWA.
Build the project for Web Mobile, then add a manifest link and theme color to index.html:
1 | <meta name="theme-color" content="#ffffff"> |
Create manifest.json with the app name, start_url, display: "standalone", colors, and 192×192 and 512×512 icons:
1 | { |
Register a service worker from the page:
1 | if ('serviceWorker' in navigator) { |
Create service-worker.js and add the caching strategy required by your game. Serve the build over HTTPS (or localhost), because production service workers require a secure context. Verify the manifest and service worker in browser DevTools before testing installation.