-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
54 lines (47 loc) · 1.57 KB
/
index.html
File metadata and controls
54 lines (47 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Music Finder</title>
<meta name="theme-color" content="#303f9f" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=3.0">
<link rel="manifest" href="./manifest.json">
</head>
<body>
<p>Follow the steps to add this page to home screen.</p>
<ul>
<li>Open Developer Tools</li>
<li>Go to Application</li>
<li>Click on Service Worker. Unregister all service worker and refresh the page.</li>
<li>Click on Manifest on the left side.</li>
<li>Click the link, Add to homescreen.</li>
</ul>
<script>
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('./sw.js').then(registration => {
console.log('SW registered: ', registration);
}).catch(registrationError => {
console.log('SW registration failed: ', registrationError);
});
});
} else {
console.log('service worker not supported');
}
window.addEventListener('beforeinstallprompt', function(e) {
// beforeinstallprompt Event fired
// e.userChoice will return a Promise.
// For more details read: https://developers.google.com/web/fundamentals/getting-started/primers/promises
e.userChoice.then(function(choiceResult) {
console.log(choiceResult.outcome);
if(choiceResult.outcome == 'dismissed') {
console.log('User cancelled home screen install');
}
else {
console.log('User added to home screen');
}
});
});
</script>
</body>
</html>