-
Notifications
You must be signed in to change notification settings - Fork 314
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1749 from Subhajit-2023-44/2
Add PWA (Progressive Web App) done !
- Loading branch information
Showing
6 changed files
with
93 additions
and
4 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "WordWise", | ||
"short_name": "WordWise", | ||
"start_url": "/", | ||
"display": "standalone", | ||
"background_color": "#ffffff", | ||
"theme_color": "#000000", | ||
"icons": [ | ||
{ | ||
"src": "/icon-192x192.png", | ||
"sizes": "192x192", | ||
"type": "image/png" | ||
}, | ||
{ | ||
"src": "/icon-512x512.png", | ||
"sizes": "512x512", | ||
"type": "image/png" | ||
} | ||
] | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Register the service worker | ||
if ('serviceWorker' in navigator) { | ||
window.addEventListener('load', () => { | ||
navigator.serviceWorker.register('/sw.js') // Pointing to the sw.js file | ||
.then(registration => { | ||
console.log('ServiceWorker registration successful:', registration); | ||
}) | ||
.catch(error => { | ||
console.error('ServiceWorker registration failed:', error); | ||
}); | ||
}); | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
const CACHE_NAME = 'my-pwa-cache-v1'; | ||
const urlsToCache = [ | ||
'/', | ||
'/index.html', | ||
'/styles.css', | ||
'/scripts.js', | ||
'/manifest.json', | ||
'/icon-192x192.png', | ||
'/icon-512x512.png' | ||
]; | ||
|
||
|
||
self.addEventListener('install', (event) => { | ||
event.waitUntil( | ||
caches.open(CACHE_NAME) | ||
.then((cache) => { | ||
return cache.addAll(urlsToCache); | ||
}) | ||
); | ||
}); | ||
|
||
|
||
self.addEventListener('fetch', (event) => { | ||
event.respondWith( | ||
caches.match(event.request) | ||
.then((response) => { | ||
return response || fetch(event.request); | ||
}) | ||
); | ||
}); | ||
|
||
|
||
self.addEventListener('activate', (event) => { | ||
const cacheWhitelist = [CACHE_NAME]; | ||
event.waitUntil( | ||
caches.keys().then((cacheNames) => { | ||
return Promise.all( | ||
cacheNames.map((cacheName) => { | ||
if (!cacheWhitelist.includes(cacheName)) { | ||
return caches.delete(cacheName); | ||
} | ||
}) | ||
); | ||
}) | ||
); | ||
}); |
bab73ba
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
word-wise – ./
word-wise-pi.vercel.app
word-wise-anshikas-projects-45924011.vercel.app
word-wise-git-main-anshikas-projects-45924011.vercel.app