250x250
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- button
- 백엔드
- HTML
- SWIFT
- 애니메이션
- 비전공자
- 개발자
- Animation
- 풀스택
- jQuery
- 비전공 개발자
- ipad
- CSS
- javascript
- MAC
- css3
- keyframes
- IOS
- hover
- php
- react
- iPhone
- iOS 개발자
- effect
- image
- html5
- xcode
- 자바스크립트
- front-end
- 프론트엔드
Archives
- Today
- Total
비전공자 개발일기
PWA Install Ready 본문
728x90
SMALL
PWA를 설치할 수 있음을 표시하고 사용자 지정 인앱 설치 흐름을 제공하는 방법
- beforeinstallprompt 이벤트 실행
// Initialize deferredPrompt for use later to show browser install prompt.
let deferredPrompt;
window.addEventListener('beforeinstallprompt', (e) => {
// Prevent the mini-infobar from appearing on mobile
e.preventDefault();
// Stash the event so it can be triggered later.
deferredPrompt = e;
// Update UI notify the user they can install the PWA
showInstallPromotion();
// Optionally, send analytics event that PWA install promo was shown.
console.log(`'beforeinstallprompt' event was fired.`);
});
2. 인앱 설치 흐름
buttonInstall.addEventListener('click', async () => {
// Hide the app provided install promotion
hideInstallPromotion();
// Show the install prompt
deferredPrompt.prompt();
// Wait for the user to respond to the prompt
const { outcome } = await deferredPrompt.userChoice;
// Optionally, send analytics event with outcome of user choice
console.log(`User response to the install prompt: ${outcome}`);
// We've used the prompt, and can't use it again, throw it away
deferredPrompt = null;
});
728x90
LIST
'기타' 카테고리의 다른 글
Pynecone (0) | 2023.01.15 |
---|---|
IPhone Toggle Switch (0) | 2022.04.10 |
모바일 웹 페이지 바로가기 아이콘 등록 (0) | 2022.04.06 |
MacBook M1에서 Homebrew 설치 + unknown command cask 문제 (0) | 2022.01.22 |
Mac Book 유용한 단축키 (0) | 2022.01.16 |