25. if ('share' in navigator) {
const shareOpts = {
title: 'Unlocking New Capabilities for the Web',
text: 'One of the most exciting talks at I/O',
url: 'https: // www.google.com',
}
navigator.share(shareOpts)
.then(() => { ...})
.catch((e) => { ...})
}
26. if ('share' in navigator) {
const shareOpts = {
title: 'Unlocking New Capabilities for the Web',
text: 'One of the most exciting talks at I/O',
url: 'https: // www.google.com',
}
navigator.share(shareOpts)
.then(() => { ...})
.catch((e) => { ...})
}
27. if ('share' in navigator) {
const shareOpts = {
title: 'Unlocking New Capabilities for the Web',
text: 'One of the most exciting talks at I/O',
url: 'https: // www.google.com',
}
navigator.share(shareOpts)
.then(() => { ...})
.catch((e) => { ...})
}
42. if ('FaceDetector' in window) {
const faces = await new FaceDetector().detect(img);
} else {
// Use fallback
}
if ('BarcodeDetector' in window) {
const codes = await new BarcodeDetector().detect(img);
} else {
// Use fallback
}
48. window.PerceptionToolkit = window.PerceptionToolkit || {};
window.PerceptionToolkit.config = {
// Where the toolkit is installed.
root: '/node_modules/perception-toolkit',
//The element to use to launch.
button: document.getElementById('get-started'),
//The container for generated cards.
cardContainer,
}
54. // Getting a "screen" wake lock
let wakeLock = await navigator.getWakeLock('screen');
// Listening for active changes
wakeLock.addEventListener('activeChange', (e) -> {
console.log(e.target);
})
// Requesting the wake lock to become active
let wakeLockRequest = wakeLock.createRequest();
// Canceling the wake lock after 1min
setTimeout(() => {
wakeLockRequest.cancel();
wakeLockRequest = null;
}, 60 * 1000 );
55. // Getting a "screen" wake lock
let wakeLock = await navigator.getWakeLock('screen');
// Listening for active changes
wakeLock.addEventListener('activeChange', (e) -> {
console.log(e.target);
})
// Requesting the wake lock to become active
let wakeLockRequest = wakeLock.createRequest();
// Canceling the wake lock after 1min
setTimeout(() => {
wakeLockRequest.cancel();
wakeLockRequest = null;
}, 60 * 1000 );
56. // Getting a "screen" wake lock
let wakeLock = await navigator.getWakeLock('screen');
// Listening for active changes
wakeLock.addEventListener('activeChange', (e) -> {
console.log(e.target);
})
// Requesting the wake lock to become active
let wakeLockRequest = wakeLock.createRequest();
// Canceling the wake lock after 1min
setTimeout(() => {
wakeLockRequest.cancel();
wakeLockRequest = null;
}, 60 * 1000 );
57. // Getting a "screen" wake lock
let wakeLock = await navigator.getWakeLock('screen');
// Listening for active changes
wakeLock.addEventListener('activeChange', (e) -> {
console.log(e.target);
})
// Requesting the wake lock to become active
let wakeLockRequest = wakeLock.createRequest();
// Canceling the wake lock after 1min
setTimeout(() => {
wakeLockRequest.cancel();
wakeLockRequest = null;
}, 60 * 1000 );
65. Demo -4
air horner를 신나게 클릭한 후,
실행할 때 눌렀던 아이콘이 어떻게 변했는지 확인합니다.
기대한 결과와 일치하나요?
66. Reference
- Unlocking New Capabilities for the Web(Google I/O ’19)
https://youtu.be/GSiUzuB-PoI
- Introduction to the Web Perception Toolkit
https://youtu.be/uj3oMwF2XIk
hdps://developers.google.com/web/updates/capabilities
hdps://codelabs.developers.google.com/codelabs/web-capabilities/#0