-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
49 lines (47 loc) · 1.51 KB
/
index.html
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
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="theme-color" content="#FFFFFF" />
<link rel="manifest" href="/manifest.json" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>하나Fun!</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
<script>
if ('serviceWorker' in navigator) {
// Register a service worker hosted at the root of the
// site using the default scope.
navigator.serviceWorker
.register('/sw.js')
.then((registration) => {
console.log('Service worker registration succeeded:', registration);
})
.catch((err) => {
console.log('Service worker registration failed:', err);
});
} else {
console.log('Service workers are not supported.');
}
let defferedPrompt;
//설치 가능한지 확인
window.addEventListener('beforeinstallprompt', (e) => {
e.preventDefault();
defferedPrompt = e;
});
// 특정 버튼 클릭 시에 앱 설치
btn.addEventListener('click', (e) => {
defferedPrompt.prompt();
defferedPrompt.userChoice.then((res) => {
if (res === 'accepted') {
console.log('The app has been installed');
}
defferedPromts = null;
});
});
</script>
</body>
</html>