CodingMSTR LogoCodingMSTR
Progressive Web App Source Code Convert Any Website to Android and IOS App

Progressive Web App Source Code Convert Any Website to Android and IOS App

Free

Progressive Web App Source Code Convert Any Website to Android and IOS App

Category: Android
Added On: August 19, 2022
Developer: By Praveen
Youtube Video

For any customization or code setup, feel free to contact us. We also offer deployment on live servers.

For any issues related to downloading, email me at devpraveenkr@gmail.com

Need additional support or customization? Contact me!

Project Screenshots

No screenshots available

Project Description

Progressive Web App Source Code
Convert Any Website to Android and IOS App




Links To Be Added in the Index Page

         
        <link rel="manifest" href="./manifest.webmanifest">
        <script src="./index.js" type="module">
            
         
    



manifest.webmanifest FILE

         
        {
            "name": "Thumbnail Downloader YouTube",
            "short_name": "Thumbnailforyt",
            "start_url": ".",
            "display": "standalone",
            "background_color": "#fff",
            "description": "Fastest YouTube Thumbnail Downloader",
            "icons": [
                {
                "src": "img/android-icon-36x36.png",
                "sizes": "36x36",
                "type": "image/png"
                },
                {
                "src": "img/android-icon-48x48.png",
                "sizes": "48x48",
                "type": "image/png"
                },
                {
                "src": "img/android-icon-72x72.png",
                "sizes": "72x72",
                "type": "image/png"
                },
                {
                "src": "img/android-icon-96x96.png",
                "sizes": "96x96",
                "type": "image/png"
                },
                {
                "src": "img/android-icon-144x144.png",
                "sizes": "144x144",
                "type": "image/png"
                },
                {
                "src": "img/android-icon-192x192.png",
                "sizes": "192x192",
                "type": "image/png"
                },
                {
                "src": "img/logo.png",
                "sizes": "512x512",
                "type": "image/png"
                }
            ]
            }
            
         
    



index.js FILE

         
        window.addEventListener('load', () => {
             registerSW();
        });

        async function registerSW() {
        if ('serviceWorker' in navigator) {
            try {
            await navigator.serviceWorker.register('./sw.js');
            } catch (e) {
            console.log(`SW registration failed`);
            }
        }
        }
            
         
    



sw.js FILE

         
        const cacheName = 'vaahan';
            const staticAssets = [
            './',
            './index.html',
            './custom.css',
            '.custom.js',
            './index.js',
            ];

            self.addEventListener('install', async e => {
            const cache = await caches.open(cacheName);
            await cache.addAll(staticAssets);
            return self.skipWaiting();
            });

            self.addEventListener('activate', e => {
            self.clients.claim();
            });

            self.addEventListener('fetch', async e => {
            const req = e.request;
            const url = new URL(req.url);

            if (url.origin === location.origin) {
                e.respondWith(cacheFirst(req));
            } else {
                e.respondWith(networkAndCache(req));
            }
            });

            async function cacheFirst(req) {
            const cache = await caches.open(cacheName);
            const cached = await cache.match(req);
            return cached || fetch(req);
            }

            async function networkAndCache(req) {
            const cache = await caches.open(cacheName);
            try {
                const fresh = await fetch(req);
                await cache.put(req, fresh.clone());
                return fresh;
            } catch (e) {
                const cached = await cache.match(req);
                return cached;
            }
            }

            
         
    

Project Demo Video