SlideShare ist ein Scribd-Unternehmen logo
1 von 66
Downloaden Sie, um offline zu lesen
Progressive Web Apps
Get your site out of the tab!
송정기 책임
Samsung Internet 개발자
웹 표준 에디터
Chromium contributor
Email: jungkee.song@samsung.com
GitHub: @jungkees
Web App Manifest
Service Worker
Push notification
Web App Manifest
Jinho Bang (romandev@nate.com)
웹(Web)은 죽었다.
앱(App)의 시대가 올것이다.
http://stories.flipkart.com/introducing-flipkart-lite/
Progressive Web App!
Progressive Web Apps
Background Sync
ServiceWorker
Push Notification
Permissions
Bluetooth&USB
Web App Manifest
Web App Manifest?
http://www.w3.org/TR/appmanifest
<link rel = ‘manifest’ href= ‘manifest.webmanifest’>
Installable Web App
{

"name": "Simple web app demo",

"short_name": "Demo",

"icons": [

{

"src": "icon-medium.png",

"sizes": "96x96"

}, {

"src": "icon-large.png",

"sizes": "192x192"

}

],

"theme_color": "#3F51B5",

"background_color": "#F5F5F5",

"display": "standalone",

"orientation": "portrait",

"start_url": "/simple-demo/?home=true"

}
click
Installable Web App
{

"name": "Simple web app demo",

"short_name": "Demo",

"icons": [

{

"src": "icon-medium.png",

"sizes": "96x96"

}, {

"src": "icon-large.png",

"sizes": "192x192"

}

],

"theme_color": "#3F51B5",

"background_color": "#F5F5F5",

"display": "standalone",

"orientation": "portrait",

"start_url": "/simple-demo/?home=true"

}
click
Installable Web App
{

"name": "Simple web app demo",

"short_name": "Demo",

"icons": [

{

"src": "icon-medium.png",

"sizes": "96x96"

}, {

"src": "icon-large.png",

"sizes": "192x192"

}

],

"theme_color": "#3F51B5",

"background_color": "#F5F5F5",

"display": "standalone",

"orientation": "portrait",

"start_url": "/simple-demo/?home=true"

}
installed
Installable Web App - Demo
{

"name": "Simple web app demo",

"short_name": "Demo",

"icons": [

{

"src": "icon-medium.png",

"sizes": "96x96"

}, {

"src": "icon-large.png",

"sizes": "192x192"

}

],

"theme_color": "#3F51B5",

"background_color": "#F5F5F5",

"display": "standalone",

"orientation": "portrait",

"start_url": "/simple-demo/?home=true"

}
Splash Screen
{

"name": "Simple web app demo",

"short_name": "Demo",

"icons": [

{

"src": "icon-medium.png",

"sizes": "96x96"

}, {

"src": "icon-large.png",

"sizes": "192x192"

}

],

"theme_color": "#3F51B5",

"background_color": "#F5F5F5",

"display": "standalone",

"orientation": "portrait",

"start_url": "/simple-demo/?home=true"

}
background_color
icons name
* Chrome implemented it using name/icon/background_color
Splash Screen - Demo
{

"name": "Simple web app demo",

"short_name": "Demo",

"icons": [

{

"src": "icon-medium.png",

"sizes": "96x96"

}, {

"src": "icon-large.png",

"sizes": "192x192"

}

],

"theme_color": "#3F51B5",

"background_color": "#F5F5F5",

"display": "standalone",

"orientation": "portrait",

"start_url": "/simple-demo/?home=true"

}
Task Manager
{

"name": "Simple web app demo",

"short_name": "Demo",

"icons": [

{

"src": "icon-medium.png",

"sizes": "96x96"

}, {

"src": "icon-large.png",

"sizes": "192x192"

}

],

"theme_color": "#3F51B5",

"background_color": "#F5F5F5",

"display": "standalone",

"orientation": "portrait",

"start_url": "/simple-demo/?home=true"

}
Display Mode (standalone)
{

"name": "Simple web app demo",

"short_name": "Demo",

"icons": [

{

"src": "icon-medium.png",

"sizes": "96x96"

}, {

"src": "icon-large.png",

"sizes": "192x192"

}

],

"theme_color": "#3F51B5",

"background_color": "#F5F5F5",

"display": "standalone",

"orientation": "portrait",

"start_url": "/simple-demo/?home=true"

}
status
bar
#3F51B5
Display Mode (fullscreen)
{

"name": "Simple web app demo",

"short_name": "Demo",

"icons": [

{

"src": "icon-medium.png",

"sizes": "96x96"

}, {

"src": "icon-large.png",

"sizes": "192x192"

}

],

"theme_color": "#3F51B5",

"background_color": "#F5F5F5",

"display": "fullscreen",

"orientation": "portrait",

"start_url": "/simple-demo/?home=true"

}
no status bar
Start URL
{

"name": "Simple web app demo",

"short_name": "Demo",

"icons": [

{

"src": "icon-medium.png",

"sizes": "96x96"

}, {

"src": "icon-large.png",

"sizes": "192x192"

}

],

"theme_color": "#3F51B5",

"background_color": "#F5F5F5",

"display": "standalone",

"orientation": "portrait",

"start_url": "/simple-demo/?home=true"

}
../simple_demo?home=true
../simple_demo
Orientation (landscape)
{

"name": "Simple web app demo",

"short_name": "Demo",

"icons": [

{

"src": "icon-medium.png",

"sizes": "96x96"

}, {

"src": "icon-large.png",

"sizes": "192x192"

}

],

"theme_color": "#3F51B5",

"background_color": "#F5F5F5",

"display": "standalone",

"orientation": "landscape",

"start_url": "/simple-demo/?home=true"

}
Manifest로 Web App을
first-class citizen으로 만들자!
Service Worker
Offline-first & Background processing
오프라인 우선
백그라운드 이벤트 처리
어디가 오프라인? 비행기 안에서만?
가능한 한 언제나!
브라우저에 진짜 없던 것
브라우저 꺼도 web push 옵니다!
그러면서 웹 그대로!
웹 서버 업데이트가 곧 앱 업데이트! URL! 웹의 장점은 바로 거기에
Lie-Fi 시! 데이터 사용할 때도!
push, sync, geofenceenter, ..
표준 현황
개발 현황
2015년 6월 네 번째 WD 그리고..
2016년 Service Worker 1 CR 계획
4.0 40+ 44 32+
Edge? Safari?
동작의 기초가 되는 개념 들
Same origin 에서 동작
Registration 기반으로 동작 ­ key는 URL scope!
Navigation 시 매칭되는 SW가 있으면 document가 control 됨
버전 관리를 위해 waiting worker, active worker 존재
fetch 이벤트
Navigation/Resource request
onfetch
Page
SW
Cache
캐시 match 시도
Match된 Response
클라이언트에 respond
Page Page
이벤트 기반 워커
Navigation/Resource request
Page
Network fetch
Response
온라인 이신가요?
충분히 온라인 이신가요?
Navigation/Resource request
Page
Network fetch
5XX
DNS 실패
Lie-Fi
너무 심한 RTT
오프라인 with Service Worker!
fetch 이벤트
Navigation/Resource request
onfetch
Page
SW
Cache 캐시 match 시도
Match된 Response
클라이언트에 respond
IDB
new
Response({
status: 200,
body: { … }
})
오프라인 우선!
fetch 이벤트
Navigation/Resource request
onfetch
Page
SW
Cache
Fetch request
캐시 match 시도
Match 실패
클라이언트에 respond
인스톨하기
var navigator.serviceWorker;
sw.register(scriptURL, { scope: scopeURL })
리소스 Pre-caching 하기
oninstall = e => { /* 여기서 캐시 */ };
fetch event 처리 하기
onfetch = e => { /* e.request에 대해 개발자 맘대로! */ };
Cache 관리
onactivate = e => { /* 안 쓰는 cache delete도 개발자의 몫 */ };
업데이트 w/ 24시간 룰
매 navigation 시 registration.update() functional event
“/assets/v1” /assets/v1/serviceworker.js
[ Registration map ]
Scope Script URL
Register
Page에서
// scope defaults to ‘/‘
var sw = navigator.serviceWorker;
sw.register(‘/assets/v1/serviceworker.js’)
.then(reg => {
console.log(‘success!’);
reg.installing.postMessage(‘Howdy from your installing page.’);
})
.catch(e => {
console.error(‘Installing the worker failed!:’, e);
});
“/bar” /bar/sw1.js
Var sw = navigator.serviceWorker;
① sw.register(‘/bar/sw1.js’, { scope: ‘/bar’ });
② sw.register(‘/foo/sw.js’, { scope: ‘/foo’ });
③ sw.register(‘/bar/sw2.js’, { scope: ‘/bar’ } );
[ Registration map ]
Scope Script URL
“/foo” /foo/sw.js
Register ­ 복수개의 registration 생성 가능
Page에서
“/bar” /bar/sw2.js ③ Replace sw1
①
②
onactivate
SW
oninstall
onfetch
Register가 trigger하는 인스톨 과정
브라우저 internal
oninstall = e => {
// pre-cache, etc.
};
onactivate = e => {
// upgrade Cache, etc.
};
onfetch = e => {
// Not yet ready
};
Fetched sw script
Fetch sw script
Update①
Install②
Activate③
onfetch
onfetch = e => {
// Not yet ready
};
Pre-cache in oninstall
// sw.js – 인스톨 과정에서 pre-caching
self.addEventListener(‘install’, function(e) {
// 명시된 모든 리소스를 성공적으로 받아 캐시 해야만 인스톨 성공
e.waitUntil(
self.caches.open(‘shellResources’).then(function(cache) {
return cache.addAll([
‘/app.html’,
‘/assets/v1/base.css’,
‘/assets/v1/app.js’,
‘/assets/v1/logo.png’,
‘/assets/v1/intro_video.webm’
]);
});
});
Delete unused caches in inactivate
self.addEventListener('activate', function(event) {
event.waitUntil(
caches.keys().then(function(cacheNames) {
return Promise.all(
cacheNames.filter(function(cacheName) {
// Return true if you want to remove this cache,
// but remember that caches are shared across
// the whole origin
}).map(function(cacheName) {
return caches.delete(cacheName);
})
);
})
);
});
https://jakearchibald.com/2014/offline-cookbook/#on-activate
Do proxy in onfetch
self.addEventListener(‘fetch’, function(e) {
// 성공적으로 인스톨 되기 전까지는 fetch 이벤트 발생 안 함
// 모든 Cache 함수는 aync 하게 동작 함. 따라서 인터페이스가 promise로 디자인 됨
e.respondWith(
self.caches.match(e.request).catch(function() {
return fetch(e.request);
}).catch(function() {
return self.caches.match(‘/fallback.html’);
})
);
});
onfetch
sw.js
Cache
캐시 match 시도
Match된 response
클라이언트에 respond
“/” /sw.js
[ Registration map ]
Scope Script URL
“/foo” /foo/sw.js
Page Navigate https://example.com/index.html
fetch 이벤트
Scope matching
Run SW
클라이언트 Match (navigation)
onfetch
sw.js
Cache 캐시 match 시도
Match된 response
클라이언트에 respond
“/” /sw.js
[ Registration map ]
Scope Script URL
“/img” /img/sw.js
Page
Fetch “https://example.com/img/flower.png
fetch 이벤트
Control
Run SW
Subresource request
Emojoy
Offline
Wikipedia
https://wiki-offline.jakearchibald.com/
was shown
Web Push

Notification
Sanghyun Park
- sh919.park@samsung.com
(dynastpsh@gmail.com)
PUSH NOTIFICATION?
PUSH NOTIFICATION 효과
72% 26%
Push Notification 에 의한
사용자 방문 시간 증가율
Push Notification 에 의해
방문한 사용자의 지출 증가율
※ Chrome dev summit 2015 Keynote
WEB PUSH!
Background Service
WEB PUSH NOTIFICATION 필수 요소
Notification UI
Push 등록/해지/이벤트
Service Worker
WEB PUSH NOTIFICATION 구성
Web Notification API
Push API
WEB PUSH
= 구독 + 받기
4.0 Chrome 42+
지원 브라우저..
Opera44
어떻게!
Service Worker
Client side proxy
Written in Javascript
Web Server
Push Service
SUBSCRIPTION
①
③
④
②
WHAT!
SUBSCRIPTION
navigator.serviceWorker.ready.then(function(registration) {

registration.pushManager.subscribe({userVisibleOnly: true})
.then(function(subscription) {

// The push subscription details needed by the
// application. server are now available, and can be
// sent to it using, for example, an XMLHttpRequest.
sendSubscriptionToServer(subscription);

}), function(error) {
// Subscription failed.

}

);

});
WHAT!
SUBSCRIPTION
navigator.serviceWorker.ready.then(function(registration) {

registration.pushManager.subscribe({userVisibleOnly: true})
.then(function(subscription) {

// The push subscription details needed by the application

// server are now available, and can be sent to it using,

// for example, an XMLHttpRequest.
sendSubscriptionToServer(subscription);

}), function(error) {
// During development it often helps to log errors to the
// console.

}

);

});
{
"name": "Simple Push Demo",
"short_name": "Push Demo",
"start_url": "/index.html?homescreen=1",
"display": "standalone",
"gcm_sender_id": "653317226796"
}
Define GCM Sender ID in Manifest.json
Service Worker
Background Service
Web Server
Push Service
①
②
③
④
RECEIVING A PUSH MESSAGE
self.addEventListener('push', function(event) {
event.waitUntil(
fetch('/notification.json').then(function(response) {
return response.json();
}).then(function(data) {
return self.registration.showNotification(data.title, {
body: data.body,
icon: data.iconUrl,
tag: data.tag,
data: { url : data.url }
});
});
);
});
REFOCUS EXISTING WINDOWS
self.addEventListener('notificationclick', function(event) {
clients.matchAll({
type: 'window'
})
.then(function(clients) {
if (clients.length > 0) {
clients[0].postMessage({ navigateTo: event.notification.data.url });
return clients[0].focus();
} else {
return clients.openWindow(event.notification.data.url);
}
})
});
Demo
발전방향..
Service Worker
Client side proxy
Written in Javascript
Web Server
Push Service
PAYLOAD
DATA
DATA
DATA
Q & A
참고자료
개념 이해
•Introduction to Service Worker
•Service Worker - first draft published
표준 리소스
•Nightly
API 사용 패턴
•The offline cookbook
•플랫폼 구현자 참고 문서
•GitHub
•Platinum Service Worker Elements
•Service Worker API MDN

Weitere ähnliche Inhalte

Was ist angesagt?

Hybrid App Platform - HyWAI 3.5
Hybrid App Platform - HyWAI 3.5Hybrid App Platform - HyWAI 3.5
Hybrid App Platform - HyWAI 3.5Jonathan Jeon
 
React 튜토리얼 2차시
React 튜토리얼 2차시React 튜토리얼 2차시
React 튜토리얼 2차시태현 김
 
Clean Front-End Development
Clean Front-End DevelopmentClean Front-End Development
Clean Front-End Development지수 윤
 
iOS App 개발 with React Native + ClojureScript
iOS App 개발 with React Native + ClojureScriptiOS App 개발 with React Native + ClojureScript
iOS App 개발 with React Native + ClojureScriptCheolhee Han
 
React Native를 사용한
 초간단 커뮤니티 앱 제작
React Native를 사용한
 초간단 커뮤니티 앱 제작React Native를 사용한
 초간단 커뮤니티 앱 제작
React Native를 사용한
 초간단 커뮤니티 앱 제작Taegon Kim
 
파크히어 Realm 사용 사례
파크히어 Realm 사용 사례파크히어 Realm 사용 사례
파크히어 Realm 사용 사례선협 이
 
Node.js
Node.jsNode.js
Node.jsymtech
 
발렌타인 웨비너 7회 - React를 이용한 웹 앱 개발 살펴보기
발렌타인 웨비너 7회 - React를 이용한 웹 앱 개발 살펴보기발렌타인 웨비너 7회 - React를 이용한 웹 앱 개발 살펴보기
발렌타인 웨비너 7회 - React를 이용한 웹 앱 개발 살펴보기DoHyun Jung
 
React 튜토리얼 1차시
React 튜토리얼 1차시React 튜토리얼 1차시
React 튜토리얼 1차시태현 김
 
Html5 web workers
Html5 web workersHtml5 web workers
Html5 web workersWoo Jin Kim
 
[115] clean fe development_윤지수
[115] clean fe development_윤지수[115] clean fe development_윤지수
[115] clean fe development_윤지수NAVER D2
 
Meteor 0.3.6 Preview
Meteor 0.3.6 PreviewMeteor 0.3.6 Preview
Meteor 0.3.6 PreviewJuntai Park
 
Vue SSR vs Prerender
Vue SSR vs PrerenderVue SSR vs Prerender
Vue SSR vs PrerenderChangwan Jun
 
Springcamp spring boot intro
Springcamp spring boot introSpringcamp spring boot intro
Springcamp spring boot introJae-il Lee
 
ReactJS로 시작하는 멀티플랫폼 개발하기
ReactJS로 시작하는 멀티플랫폼 개발하기ReactJS로 시작하는 멀티플랫폼 개발하기
ReactJS로 시작하는 멀티플랫폼 개발하기Taegon Kim
 
React를 이용하여 멀티플랫폼에서 개발하기
React를 이용하여 멀티플랫폼에서 개발하기React를 이용하여 멀티플랫폼에서 개발하기
React를 이용하여 멀티플랫폼에서 개발하기WebFrameworks
 

Was ist angesagt? (20)

Hybrid App Platform - HyWAI 3.5
Hybrid App Platform - HyWAI 3.5Hybrid App Platform - HyWAI 3.5
Hybrid App Platform - HyWAI 3.5
 
React 튜토리얼 2차시
React 튜토리얼 2차시React 튜토리얼 2차시
React 튜토리얼 2차시
 
Clean Front-End Development
Clean Front-End DevelopmentClean Front-End Development
Clean Front-End Development
 
iOS App 개발 with React Native + ClojureScript
iOS App 개발 with React Native + ClojureScriptiOS App 개발 with React Native + ClojureScript
iOS App 개발 with React Native + ClojureScript
 
React Native를 사용한
 초간단 커뮤니티 앱 제작
React Native를 사용한
 초간단 커뮤니티 앱 제작React Native를 사용한
 초간단 커뮤니티 앱 제작
React Native를 사용한
 초간단 커뮤니티 앱 제작
 
파크히어 Realm 사용 사례
파크히어 Realm 사용 사례파크히어 Realm 사용 사례
파크히어 Realm 사용 사례
 
Node.js
Node.jsNode.js
Node.js
 
Spring Boot 2
Spring Boot 2Spring Boot 2
Spring Boot 2
 
발렌타인 웨비너 7회 - React를 이용한 웹 앱 개발 살펴보기
발렌타인 웨비너 7회 - React를 이용한 웹 앱 개발 살펴보기발렌타인 웨비너 7회 - React를 이용한 웹 앱 개발 살펴보기
발렌타인 웨비너 7회 - React를 이용한 웹 앱 개발 살펴보기
 
React 튜토리얼 1차시
React 튜토리얼 1차시React 튜토리얼 1차시
React 튜토리얼 1차시
 
Html5 web workers
Html5 web workersHtml5 web workers
Html5 web workers
 
[115] clean fe development_윤지수
[115] clean fe development_윤지수[115] clean fe development_윤지수
[115] clean fe development_윤지수
 
Meteor 0.3.6 Preview
Meteor 0.3.6 PreviewMeteor 0.3.6 Preview
Meteor 0.3.6 Preview
 
How to Grunt.js
How to Grunt.jsHow to Grunt.js
How to Grunt.js
 
Spring Boot 1
Spring Boot 1Spring Boot 1
Spring Boot 1
 
Vue SSR vs Prerender
Vue SSR vs PrerenderVue SSR vs Prerender
Vue SSR vs Prerender
 
Meteor2015 codelab
Meteor2015 codelab Meteor2015 codelab
Meteor2015 codelab
 
Springcamp spring boot intro
Springcamp spring boot introSpringcamp spring boot intro
Springcamp spring boot intro
 
ReactJS로 시작하는 멀티플랫폼 개발하기
ReactJS로 시작하는 멀티플랫폼 개발하기ReactJS로 시작하는 멀티플랫폼 개발하기
ReactJS로 시작하는 멀티플랫폼 개발하기
 
React를 이용하여 멀티플랫폼에서 개발하기
React를 이용하여 멀티플랫폼에서 개발하기React를 이용하여 멀티플랫폼에서 개발하기
React를 이용하여 멀티플랫폼에서 개발하기
 

Andere mochten auch

Samsung Internet 4.0
Samsung Internet 4.0Samsung Internet 4.0
Samsung Internet 4.0jungkees
 
프론트엔드스터디 E02 css dom
프론트엔드스터디 E02 css dom프론트엔드스터디 E02 css dom
프론트엔드스터디 E02 css domYoung-Beom Rhee
 
프론트엔드스터디 E05 js closure oop
프론트엔드스터디 E05 js closure oop프론트엔드스터디 E05 js closure oop
프론트엔드스터디 E05 js closure oopYoung-Beom Rhee
 
자바카페 프론트엔드스터디 E01 - HTML5
자바카페 프론트엔드스터디 E01 - HTML5자바카페 프론트엔드스터디 E01 - HTML5
자바카페 프론트엔드스터디 E01 - HTML5Young-Beom Rhee
 
프론트엔드스터디 E03 - Javascript intro.
프론트엔드스터디 E03 - Javascript intro.프론트엔드스터디 E03 - Javascript intro.
프론트엔드스터디 E03 - Javascript intro.Young-Beom Rhee
 
프론트엔드스터디 E04 js function
프론트엔드스터디 E04 js function프론트엔드스터디 E04 js function
프론트엔드스터디 E04 js functionYoung-Beom Rhee
 
CSS Round Display KIG 발표자료
CSS Round Display KIG 발표자료CSS Round Display KIG 발표자료
CSS Round Display KIG 발표자료Hyojin Song
 
(2015년 상반기) HTML5 및 Hybrid app 최신 동향
(2015년 상반기) HTML5 및 Hybrid app 최신 동향(2015년 상반기) HTML5 및 Hybrid app 최신 동향
(2015년 상반기) HTML5 및 Hybrid app 최신 동향Wonsuk Lee
 
[D2 COMMUNITY] ECMAScript 2015 S67 seminar - 2. functions
[D2 COMMUNITY] ECMAScript 2015 S67 seminar - 2. functions[D2 COMMUNITY] ECMAScript 2015 S67 seminar - 2. functions
[D2 COMMUNITY] ECMAScript 2015 S67 seminar - 2. functionsNAVER D2
 
[D2 COMMUNITY] ECMAScript 2015 S67 seminar - 3. generator
[D2 COMMUNITY] ECMAScript 2015 S67 seminar - 3. generator[D2 COMMUNITY] ECMAScript 2015 S67 seminar - 3. generator
[D2 COMMUNITY] ECMAScript 2015 S67 seminar - 3. generatorNAVER D2
 
[D2 COMMUNITY] ECMAScript 2015 S67 seminar - 1. primitive
[D2 COMMUNITY] ECMAScript 2015 S67 seminar - 1. primitive[D2 COMMUNITY] ECMAScript 2015 S67 seminar - 1. primitive
[D2 COMMUNITY] ECMAScript 2015 S67 seminar - 1. primitiveNAVER D2
 
오픈소스 맛보기 - 정민우님
오픈소스 맛보기 - 정민우님오픈소스 맛보기 - 정민우님
오픈소스 맛보기 - 정민우님NAVER D2
 
개알못의 오픈소스이야기 - 이상준님
개알못의 오픈소스이야기 - 이상준님개알못의 오픈소스이야기 - 이상준님
개알못의 오픈소스이야기 - 이상준님NAVER D2
 
오픈소스 SW 라이선스 - 박은정님
오픈소스 SW 라이선스 - 박은정님오픈소스 SW 라이선스 - 박은정님
오픈소스 SW 라이선스 - 박은정님NAVER D2
 
“How can we face Facebook?”
“How can we face Facebook?”“How can we face Facebook?”
“How can we face Facebook?”Coreconsulting
 
San Diego Daily Transcript - PR Newswire Event July 2009
San Diego Daily Transcript - PR Newswire Event July 2009San Diego Daily Transcript - PR Newswire Event July 2009
San Diego Daily Transcript - PR Newswire Event July 2009Michael Pranikoff
 
The Hitchhiker's Guide to Building a Progressive Web App
The Hitchhiker's Guide to Building a Progressive Web AppThe Hitchhiker's Guide to Building a Progressive Web App
The Hitchhiker's Guide to Building a Progressive Web AppChristopher Nguyen
 
Demystifying progressive web apps
Demystifying progressive web appsDemystifying progressive web apps
Demystifying progressive web appsMarcus Hellberg
 
PWA 101
PWA 101PWA 101
PWA 101m_catt
 
[STONE BID] 무엇이 오스카를 특별하게 만드는가 by Kriss Gim
[STONE BID] 무엇이 오스카를 특별하게 만드는가 by Kriss Gim[STONE BID] 무엇이 오스카를 특별하게 만드는가 by Kriss Gim
[STONE BID] 무엇이 오스카를 특별하게 만드는가 by Kriss GimSTONE BRAND COMMUNICATIONS
 

Andere mochten auch (20)

Samsung Internet 4.0
Samsung Internet 4.0Samsung Internet 4.0
Samsung Internet 4.0
 
프론트엔드스터디 E02 css dom
프론트엔드스터디 E02 css dom프론트엔드스터디 E02 css dom
프론트엔드스터디 E02 css dom
 
프론트엔드스터디 E05 js closure oop
프론트엔드스터디 E05 js closure oop프론트엔드스터디 E05 js closure oop
프론트엔드스터디 E05 js closure oop
 
자바카페 프론트엔드스터디 E01 - HTML5
자바카페 프론트엔드스터디 E01 - HTML5자바카페 프론트엔드스터디 E01 - HTML5
자바카페 프론트엔드스터디 E01 - HTML5
 
프론트엔드스터디 E03 - Javascript intro.
프론트엔드스터디 E03 - Javascript intro.프론트엔드스터디 E03 - Javascript intro.
프론트엔드스터디 E03 - Javascript intro.
 
프론트엔드스터디 E04 js function
프론트엔드스터디 E04 js function프론트엔드스터디 E04 js function
프론트엔드스터디 E04 js function
 
CSS Round Display KIG 발표자료
CSS Round Display KIG 발표자료CSS Round Display KIG 발표자료
CSS Round Display KIG 발표자료
 
(2015년 상반기) HTML5 및 Hybrid app 최신 동향
(2015년 상반기) HTML5 및 Hybrid app 최신 동향(2015년 상반기) HTML5 및 Hybrid app 최신 동향
(2015년 상반기) HTML5 및 Hybrid app 최신 동향
 
[D2 COMMUNITY] ECMAScript 2015 S67 seminar - 2. functions
[D2 COMMUNITY] ECMAScript 2015 S67 seminar - 2. functions[D2 COMMUNITY] ECMAScript 2015 S67 seminar - 2. functions
[D2 COMMUNITY] ECMAScript 2015 S67 seminar - 2. functions
 
[D2 COMMUNITY] ECMAScript 2015 S67 seminar - 3. generator
[D2 COMMUNITY] ECMAScript 2015 S67 seminar - 3. generator[D2 COMMUNITY] ECMAScript 2015 S67 seminar - 3. generator
[D2 COMMUNITY] ECMAScript 2015 S67 seminar - 3. generator
 
[D2 COMMUNITY] ECMAScript 2015 S67 seminar - 1. primitive
[D2 COMMUNITY] ECMAScript 2015 S67 seminar - 1. primitive[D2 COMMUNITY] ECMAScript 2015 S67 seminar - 1. primitive
[D2 COMMUNITY] ECMAScript 2015 S67 seminar - 1. primitive
 
오픈소스 맛보기 - 정민우님
오픈소스 맛보기 - 정민우님오픈소스 맛보기 - 정민우님
오픈소스 맛보기 - 정민우님
 
개알못의 오픈소스이야기 - 이상준님
개알못의 오픈소스이야기 - 이상준님개알못의 오픈소스이야기 - 이상준님
개알못의 오픈소스이야기 - 이상준님
 
오픈소스 SW 라이선스 - 박은정님
오픈소스 SW 라이선스 - 박은정님오픈소스 SW 라이선스 - 박은정님
오픈소스 SW 라이선스 - 박은정님
 
“How can we face Facebook?”
“How can we face Facebook?”“How can we face Facebook?”
“How can we face Facebook?”
 
San Diego Daily Transcript - PR Newswire Event July 2009
San Diego Daily Transcript - PR Newswire Event July 2009San Diego Daily Transcript - PR Newswire Event July 2009
San Diego Daily Transcript - PR Newswire Event July 2009
 
The Hitchhiker's Guide to Building a Progressive Web App
The Hitchhiker's Guide to Building a Progressive Web AppThe Hitchhiker's Guide to Building a Progressive Web App
The Hitchhiker's Guide to Building a Progressive Web App
 
Demystifying progressive web apps
Demystifying progressive web appsDemystifying progressive web apps
Demystifying progressive web apps
 
PWA 101
PWA 101PWA 101
PWA 101
 
[STONE BID] 무엇이 오스카를 특별하게 만드는가 by Kriss Gim
[STONE BID] 무엇이 오스카를 특별하게 만드는가 by Kriss Gim[STONE BID] 무엇이 오스카를 특별하게 만드는가 by Kriss Gim
[STONE BID] 무엇이 오스카를 특별하게 만드는가 by Kriss Gim
 

Ähnlich wie Progressive Web Apps

캠프앱 개발 사례를 통해 본 하이브리드앱 어디까지 | Devon 2012
캠프앱 개발 사례를 통해 본 하이브리드앱 어디까지 | Devon 2012캠프앱 개발 사례를 통해 본 하이브리드앱 어디까지 | Devon 2012
캠프앱 개발 사례를 통해 본 하이브리드앱 어디까지 | Devon 2012Daum DNA
 
웹 Front-End 실무 이야기
웹 Front-End 실무 이야기웹 Front-End 실무 이야기
웹 Front-End 실무 이야기JinKwon Lee
 
조은 - AMP PWA 101 [WSConf.Seoul.2017. Vol.2]
조은 - AMP PWA 101 [WSConf.Seoul.2017. Vol.2]조은 - AMP PWA 101 [WSConf.Seoul.2017. Vol.2]
조은 - AMP PWA 101 [WSConf.Seoul.2017. Vol.2]WSConf.
 
Angularjs, ionic, cordova 기반 syrup store app 개발 사례 공유
Angularjs, ionic, cordova 기반 syrup store app 개발 사례 공유Angularjs, ionic, cordova 기반 syrup store app 개발 사례 공유
Angularjs, ionic, cordova 기반 syrup store app 개발 사례 공유Sang Seok Lim
 
20170813 django api server unit test and remote debugging
20170813 django api server unit test and remote debugging20170813 django api server unit test and remote debugging
20170813 django api server unit test and remote debuggingJongwon Han
 
Service Worker 를 이용한 
Offline Web Application 구현
Service Worker 를 이용한 
Offline Web Application 구현Service Worker 를 이용한 
Offline Web Application 구현
Service Worker 를 이용한 
Offline Web Application 구현병태 정
 
코드로 바로 해버리는 서버리스 오케스트레이션 - Azure Durable Functions
코드로 바로 해버리는 서버리스 오케스트레이션 - Azure Durable Functions코드로 바로 해버리는 서버리스 오케스트레이션 - Azure Durable Functions
코드로 바로 해버리는 서버리스 오케스트레이션 - Azure Durable FunctionsJongin Lee
 
도구를 활용한 더 나은 웹 개발: Yeoman
도구를 활용한 더 나은 웹 개발: Yeoman도구를 활용한 더 나은 웹 개발: Yeoman
도구를 활용한 더 나은 웹 개발: YeomanJae Sung Park
 
NODE.JS 글로벌 기업 적용 사례 그리고, real-time 어플리케이션 개발하기
NODE.JS 글로벌 기업 적용 사례  그리고, real-time 어플리케이션 개발하기NODE.JS 글로벌 기업 적용 사례  그리고, real-time 어플리케이션 개발하기
NODE.JS 글로벌 기업 적용 사례 그리고, real-time 어플리케이션 개발하기John Kim
 
[124] 하이브리드 앱 개발기 김한솔
[124] 하이브리드 앱 개발기 김한솔[124] 하이브리드 앱 개발기 김한솔
[124] 하이브리드 앱 개발기 김한솔NAVER D2
 
PWA 파헤치기
PWA 파헤치기PWA 파헤치기
PWA 파헤치기SangHun Lee
 
[145]5년간의네이버웹엔진개발삽질기그리고 김효
[145]5년간의네이버웹엔진개발삽질기그리고 김효[145]5년간의네이버웹엔진개발삽질기그리고 김효
[145]5년간의네이버웹엔진개발삽질기그리고 김효NAVER D2
 
[Azure bootcamp2017] Azure App Service로 서비스 탄탄하게 관리하기
[Azure bootcamp2017] Azure App Service로 서비스 탄탄하게 관리하기[Azure bootcamp2017] Azure App Service로 서비스 탄탄하게 관리하기
[Azure bootcamp2017] Azure App Service로 서비스 탄탄하게 관리하기Youngjae Kim
 
PHP Slim Framework with Angular
PHP Slim Framework with AngularPHP Slim Framework with Angular
PHP Slim Framework with AngularJT Jintae Jung
 
[D2 오픈세미나]3.web view hybridapp
[D2 오픈세미나]3.web view hybridapp[D2 오픈세미나]3.web view hybridapp
[D2 오픈세미나]3.web view hybridappNAVER D2
 
Introduce Yeoman
Introduce YeomanIntroduce Yeoman
Introduce Yeoman항희 이
 
리멤버 데스크톱 앱 개발기
리멤버 데스크톱 앱 개발기리멤버 데스크톱 앱 개발기
리멤버 데스크톱 앱 개발기Tom Kim
 
[121]네이버 효과툰 구현 이야기
[121]네이버 효과툰 구현 이야기[121]네이버 효과툰 구현 이야기
[121]네이버 효과툰 구현 이야기NAVER D2
 

Ähnlich wie Progressive Web Apps (20)

캠프앱 개발 사례를 통해 본 하이브리드앱 어디까지 | Devon 2012
캠프앱 개발 사례를 통해 본 하이브리드앱 어디까지 | Devon 2012캠프앱 개발 사례를 통해 본 하이브리드앱 어디까지 | Devon 2012
캠프앱 개발 사례를 통해 본 하이브리드앱 어디까지 | Devon 2012
 
웹 Front-End 실무 이야기
웹 Front-End 실무 이야기웹 Front-End 실무 이야기
웹 Front-End 실무 이야기
 
7. html5 api
7. html5 api7. html5 api
7. html5 api
 
조은 - AMP PWA 101 [WSConf.Seoul.2017. Vol.2]
조은 - AMP PWA 101 [WSConf.Seoul.2017. Vol.2]조은 - AMP PWA 101 [WSConf.Seoul.2017. Vol.2]
조은 - AMP PWA 101 [WSConf.Seoul.2017. Vol.2]
 
Angularjs, ionic, cordova 기반 syrup store app 개발 사례 공유
Angularjs, ionic, cordova 기반 syrup store app 개발 사례 공유Angularjs, ionic, cordova 기반 syrup store app 개발 사례 공유
Angularjs, ionic, cordova 기반 syrup store app 개발 사례 공유
 
20170813 django api server unit test and remote debugging
20170813 django api server unit test and remote debugging20170813 django api server unit test and remote debugging
20170813 django api server unit test and remote debugging
 
Service Worker 를 이용한 
Offline Web Application 구현
Service Worker 를 이용한 
Offline Web Application 구현Service Worker 를 이용한 
Offline Web Application 구현
Service Worker 를 이용한 
Offline Web Application 구현
 
코드로 바로 해버리는 서버리스 오케스트레이션 - Azure Durable Functions
코드로 바로 해버리는 서버리스 오케스트레이션 - Azure Durable Functions코드로 바로 해버리는 서버리스 오케스트레이션 - Azure Durable Functions
코드로 바로 해버리는 서버리스 오케스트레이션 - Azure Durable Functions
 
도구를 활용한 더 나은 웹 개발: Yeoman
도구를 활용한 더 나은 웹 개발: Yeoman도구를 활용한 더 나은 웹 개발: Yeoman
도구를 활용한 더 나은 웹 개발: Yeoman
 
NODE.JS 글로벌 기업 적용 사례 그리고, real-time 어플리케이션 개발하기
NODE.JS 글로벌 기업 적용 사례  그리고, real-time 어플리케이션 개발하기NODE.JS 글로벌 기업 적용 사례  그리고, real-time 어플리케이션 개발하기
NODE.JS 글로벌 기업 적용 사례 그리고, real-time 어플리케이션 개발하기
 
[124] 하이브리드 앱 개발기 김한솔
[124] 하이브리드 앱 개발기 김한솔[124] 하이브리드 앱 개발기 김한솔
[124] 하이브리드 앱 개발기 김한솔
 
PWA 파헤치기
PWA 파헤치기PWA 파헤치기
PWA 파헤치기
 
[145]5년간의네이버웹엔진개발삽질기그리고 김효
[145]5년간의네이버웹엔진개발삽질기그리고 김효[145]5년간의네이버웹엔진개발삽질기그리고 김효
[145]5년간의네이버웹엔진개발삽질기그리고 김효
 
[Azure bootcamp2017] Azure App Service로 서비스 탄탄하게 관리하기
[Azure bootcamp2017] Azure App Service로 서비스 탄탄하게 관리하기[Azure bootcamp2017] Azure App Service로 서비스 탄탄하게 관리하기
[Azure bootcamp2017] Azure App Service로 서비스 탄탄하게 관리하기
 
PHP Slim Framework with Angular
PHP Slim Framework with AngularPHP Slim Framework with Angular
PHP Slim Framework with Angular
 
[D2 오픈세미나]3.web view hybridapp
[D2 오픈세미나]3.web view hybridapp[D2 오픈세미나]3.web view hybridapp
[D2 오픈세미나]3.web view hybridapp
 
Introduce Yeoman
Introduce YeomanIntroduce Yeoman
Introduce Yeoman
 
리멤버 데스크톱 앱 개발기
리멤버 데스크톱 앱 개발기리멤버 데스크톱 앱 개발기
리멤버 데스크톱 앱 개발기
 
[121]네이버 효과툰 구현 이야기
[121]네이버 효과툰 구현 이야기[121]네이버 효과툰 구현 이야기
[121]네이버 효과툰 구현 이야기
 
okspring3x
okspring3xokspring3x
okspring3x
 

Mehr von jungkees

PWA Roadshow Korea - Service Worker
PWA Roadshow Korea - Service WorkerPWA Roadshow Korea - Service Worker
PWA Roadshow Korea - Service Workerjungkees
 
Service Worker - Reliability bits
Service Worker - Reliability bitsService Worker - Reliability bits
Service Worker - Reliability bitsjungkees
 
Service Worker at W3C HTML5 Conference in Seoul on the 9th of Dec 2015
Service Worker at W3C HTML5 Conference in Seoul on the 9th of Dec 2015Service Worker at W3C HTML5 Conference in Seoul on the 9th of Dec 2015
Service Worker at W3C HTML5 Conference in Seoul on the 9th of Dec 2015jungkees
 
Service workers
Service workersService workers
Service workersjungkees
 
Do you Promise?
Do you Promise?Do you Promise?
Do you Promise?jungkees
 
Progress Events Web Apps F2F at San Jose
Progress Events Web Apps F2F at San JoseProgress Events Web Apps F2F at San Jose
Progress Events Web Apps F2F at San Josejungkees
 
XHR Web APps F2F at San Jose
XHR Web APps F2F at San JoseXHR Web APps F2F at San Jose
XHR Web APps F2F at San Josejungkees
 

Mehr von jungkees (7)

PWA Roadshow Korea - Service Worker
PWA Roadshow Korea - Service WorkerPWA Roadshow Korea - Service Worker
PWA Roadshow Korea - Service Worker
 
Service Worker - Reliability bits
Service Worker - Reliability bitsService Worker - Reliability bits
Service Worker - Reliability bits
 
Service Worker at W3C HTML5 Conference in Seoul on the 9th of Dec 2015
Service Worker at W3C HTML5 Conference in Seoul on the 9th of Dec 2015Service Worker at W3C HTML5 Conference in Seoul on the 9th of Dec 2015
Service Worker at W3C HTML5 Conference in Seoul on the 9th of Dec 2015
 
Service workers
Service workersService workers
Service workers
 
Do you Promise?
Do you Promise?Do you Promise?
Do you Promise?
 
Progress Events Web Apps F2F at San Jose
Progress Events Web Apps F2F at San JoseProgress Events Web Apps F2F at San Jose
Progress Events Web Apps F2F at San Jose
 
XHR Web APps F2F at San Jose
XHR Web APps F2F at San JoseXHR Web APps F2F at San Jose
XHR Web APps F2F at San Jose
 

Progressive Web Apps

  • 1. Progressive Web Apps Get your site out of the tab!
  • 2. 송정기 책임 Samsung Internet 개발자 웹 표준 에디터 Chromium contributor Email: jungkee.song@samsung.com GitHub: @jungkees
  • 3. Web App Manifest Service Worker Push notification
  • 4. Web App Manifest Jinho Bang (romandev@nate.com)
  • 6.
  • 7.
  • 9. Progressive Web Apps Background Sync ServiceWorker Push Notification Permissions Bluetooth&USB Web App Manifest
  • 11. <link rel = ‘manifest’ href= ‘manifest.webmanifest’>
  • 12. Installable Web App {
 "name": "Simple web app demo",
 "short_name": "Demo",
 "icons": [
 {
 "src": "icon-medium.png",
 "sizes": "96x96"
 }, {
 "src": "icon-large.png",
 "sizes": "192x192"
 }
 ],
 "theme_color": "#3F51B5",
 "background_color": "#F5F5F5",
 "display": "standalone",
 "orientation": "portrait",
 "start_url": "/simple-demo/?home=true"
 } click
  • 13. Installable Web App {
 "name": "Simple web app demo",
 "short_name": "Demo",
 "icons": [
 {
 "src": "icon-medium.png",
 "sizes": "96x96"
 }, {
 "src": "icon-large.png",
 "sizes": "192x192"
 }
 ],
 "theme_color": "#3F51B5",
 "background_color": "#F5F5F5",
 "display": "standalone",
 "orientation": "portrait",
 "start_url": "/simple-demo/?home=true"
 } click
  • 14. Installable Web App {
 "name": "Simple web app demo",
 "short_name": "Demo",
 "icons": [
 {
 "src": "icon-medium.png",
 "sizes": "96x96"
 }, {
 "src": "icon-large.png",
 "sizes": "192x192"
 }
 ],
 "theme_color": "#3F51B5",
 "background_color": "#F5F5F5",
 "display": "standalone",
 "orientation": "portrait",
 "start_url": "/simple-demo/?home=true"
 } installed
  • 15. Installable Web App - Demo {
 "name": "Simple web app demo",
 "short_name": "Demo",
 "icons": [
 {
 "src": "icon-medium.png",
 "sizes": "96x96"
 }, {
 "src": "icon-large.png",
 "sizes": "192x192"
 }
 ],
 "theme_color": "#3F51B5",
 "background_color": "#F5F5F5",
 "display": "standalone",
 "orientation": "portrait",
 "start_url": "/simple-demo/?home=true"
 }
  • 16. Splash Screen {
 "name": "Simple web app demo",
 "short_name": "Demo",
 "icons": [
 {
 "src": "icon-medium.png",
 "sizes": "96x96"
 }, {
 "src": "icon-large.png",
 "sizes": "192x192"
 }
 ],
 "theme_color": "#3F51B5",
 "background_color": "#F5F5F5",
 "display": "standalone",
 "orientation": "portrait",
 "start_url": "/simple-demo/?home=true"
 } background_color icons name * Chrome implemented it using name/icon/background_color
  • 17. Splash Screen - Demo {
 "name": "Simple web app demo",
 "short_name": "Demo",
 "icons": [
 {
 "src": "icon-medium.png",
 "sizes": "96x96"
 }, {
 "src": "icon-large.png",
 "sizes": "192x192"
 }
 ],
 "theme_color": "#3F51B5",
 "background_color": "#F5F5F5",
 "display": "standalone",
 "orientation": "portrait",
 "start_url": "/simple-demo/?home=true"
 }
  • 18. Task Manager {
 "name": "Simple web app demo",
 "short_name": "Demo",
 "icons": [
 {
 "src": "icon-medium.png",
 "sizes": "96x96"
 }, {
 "src": "icon-large.png",
 "sizes": "192x192"
 }
 ],
 "theme_color": "#3F51B5",
 "background_color": "#F5F5F5",
 "display": "standalone",
 "orientation": "portrait",
 "start_url": "/simple-demo/?home=true"
 }
  • 19. Display Mode (standalone) {
 "name": "Simple web app demo",
 "short_name": "Demo",
 "icons": [
 {
 "src": "icon-medium.png",
 "sizes": "96x96"
 }, {
 "src": "icon-large.png",
 "sizes": "192x192"
 }
 ],
 "theme_color": "#3F51B5",
 "background_color": "#F5F5F5",
 "display": "standalone",
 "orientation": "portrait",
 "start_url": "/simple-demo/?home=true"
 } status bar #3F51B5
  • 20. Display Mode (fullscreen) {
 "name": "Simple web app demo",
 "short_name": "Demo",
 "icons": [
 {
 "src": "icon-medium.png",
 "sizes": "96x96"
 }, {
 "src": "icon-large.png",
 "sizes": "192x192"
 }
 ],
 "theme_color": "#3F51B5",
 "background_color": "#F5F5F5",
 "display": "fullscreen",
 "orientation": "portrait",
 "start_url": "/simple-demo/?home=true"
 } no status bar
  • 21. Start URL {
 "name": "Simple web app demo",
 "short_name": "Demo",
 "icons": [
 {
 "src": "icon-medium.png",
 "sizes": "96x96"
 }, {
 "src": "icon-large.png",
 "sizes": "192x192"
 }
 ],
 "theme_color": "#3F51B5",
 "background_color": "#F5F5F5",
 "display": "standalone",
 "orientation": "portrait",
 "start_url": "/simple-demo/?home=true"
 } ../simple_demo?home=true ../simple_demo
  • 22. Orientation (landscape) {
 "name": "Simple web app demo",
 "short_name": "Demo",
 "icons": [
 {
 "src": "icon-medium.png",
 "sizes": "96x96"
 }, {
 "src": "icon-large.png",
 "sizes": "192x192"
 }
 ],
 "theme_color": "#3F51B5",
 "background_color": "#F5F5F5",
 "display": "standalone",
 "orientation": "landscape",
 "start_url": "/simple-demo/?home=true"
 }
  • 23. Manifest로 Web App을 first-class citizen으로 만들자!
  • 24. Service Worker Offline-first & Background processing
  • 25. 오프라인 우선 백그라운드 이벤트 처리 어디가 오프라인? 비행기 안에서만? 가능한 한 언제나! 브라우저에 진짜 없던 것 브라우저 꺼도 web push 옵니다! 그러면서 웹 그대로! 웹 서버 업데이트가 곧 앱 업데이트! URL! 웹의 장점은 바로 거기에 Lie-Fi 시! 데이터 사용할 때도! push, sync, geofenceenter, ..
  • 26. 표준 현황 개발 현황 2015년 6월 네 번째 WD 그리고.. 2016년 Service Worker 1 CR 계획 4.0 40+ 44 32+ Edge? Safari?
  • 27. 동작의 기초가 되는 개념 들 Same origin 에서 동작 Registration 기반으로 동작 ­ key는 URL scope! Navigation 시 매칭되는 SW가 있으면 document가 control 됨 버전 관리를 위해 waiting worker, active worker 존재
  • 28. fetch 이벤트 Navigation/Resource request onfetch Page SW Cache 캐시 match 시도 Match된 Response 클라이언트에 respond Page Page 이벤트 기반 워커
  • 30. 충분히 온라인 이신가요? Navigation/Resource request Page Network fetch 5XX DNS 실패 Lie-Fi 너무 심한 RTT
  • 31. 오프라인 with Service Worker! fetch 이벤트 Navigation/Resource request onfetch Page SW Cache 캐시 match 시도 Match된 Response 클라이언트에 respond IDB new Response({ status: 200, body: { … } })
  • 32. 오프라인 우선! fetch 이벤트 Navigation/Resource request onfetch Page SW Cache Fetch request 캐시 match 시도 Match 실패 클라이언트에 respond
  • 33. 인스톨하기 var navigator.serviceWorker; sw.register(scriptURL, { scope: scopeURL }) 리소스 Pre-caching 하기 oninstall = e => { /* 여기서 캐시 */ }; fetch event 처리 하기 onfetch = e => { /* e.request에 대해 개발자 맘대로! */ }; Cache 관리 onactivate = e => { /* 안 쓰는 cache delete도 개발자의 몫 */ }; 업데이트 w/ 24시간 룰 매 navigation 시 registration.update() functional event
  • 34. “/assets/v1” /assets/v1/serviceworker.js [ Registration map ] Scope Script URL Register Page에서 // scope defaults to ‘/‘ var sw = navigator.serviceWorker; sw.register(‘/assets/v1/serviceworker.js’) .then(reg => { console.log(‘success!’); reg.installing.postMessage(‘Howdy from your installing page.’); }) .catch(e => { console.error(‘Installing the worker failed!:’, e); });
  • 35. “/bar” /bar/sw1.js Var sw = navigator.serviceWorker; ① sw.register(‘/bar/sw1.js’, { scope: ‘/bar’ }); ② sw.register(‘/foo/sw.js’, { scope: ‘/foo’ }); ③ sw.register(‘/bar/sw2.js’, { scope: ‘/bar’ } ); [ Registration map ] Scope Script URL “/foo” /foo/sw.js Register ­ 복수개의 registration 생성 가능 Page에서 “/bar” /bar/sw2.js ③ Replace sw1 ① ②
  • 36. onactivate SW oninstall onfetch Register가 trigger하는 인스톨 과정 브라우저 internal oninstall = e => { // pre-cache, etc. }; onactivate = e => { // upgrade Cache, etc. }; onfetch = e => { // Not yet ready }; Fetched sw script Fetch sw script Update① Install② Activate③ onfetch onfetch = e => { // Not yet ready };
  • 37. Pre-cache in oninstall // sw.js – 인스톨 과정에서 pre-caching self.addEventListener(‘install’, function(e) { // 명시된 모든 리소스를 성공적으로 받아 캐시 해야만 인스톨 성공 e.waitUntil( self.caches.open(‘shellResources’).then(function(cache) { return cache.addAll([ ‘/app.html’, ‘/assets/v1/base.css’, ‘/assets/v1/app.js’, ‘/assets/v1/logo.png’, ‘/assets/v1/intro_video.webm’ ]); }); });
  • 38. Delete unused caches in inactivate self.addEventListener('activate', function(event) { event.waitUntil( caches.keys().then(function(cacheNames) { return Promise.all( cacheNames.filter(function(cacheName) { // Return true if you want to remove this cache, // but remember that caches are shared across // the whole origin }).map(function(cacheName) { return caches.delete(cacheName); }) ); }) ); }); https://jakearchibald.com/2014/offline-cookbook/#on-activate
  • 39. Do proxy in onfetch self.addEventListener(‘fetch’, function(e) { // 성공적으로 인스톨 되기 전까지는 fetch 이벤트 발생 안 함 // 모든 Cache 함수는 aync 하게 동작 함. 따라서 인터페이스가 promise로 디자인 됨 e.respondWith( self.caches.match(e.request).catch(function() { return fetch(e.request); }).catch(function() { return self.caches.match(‘/fallback.html’); }) ); });
  • 40. onfetch sw.js Cache 캐시 match 시도 Match된 response 클라이언트에 respond “/” /sw.js [ Registration map ] Scope Script URL “/foo” /foo/sw.js Page Navigate https://example.com/index.html fetch 이벤트 Scope matching Run SW 클라이언트 Match (navigation)
  • 41. onfetch sw.js Cache 캐시 match 시도 Match된 response 클라이언트에 respond “/” /sw.js [ Registration map ] Scope Script URL “/img” /img/sw.js Page Fetch “https://example.com/img/flower.png fetch 이벤트 Control Run SW Subresource request
  • 44. Web Push
 Notification Sanghyun Park - sh919.park@samsung.com (dynastpsh@gmail.com)
  • 46.
  • 47. PUSH NOTIFICATION 효과 72% 26% Push Notification 에 의한 사용자 방문 시간 증가율 Push Notification 에 의해 방문한 사용자의 지출 증가율 ※ Chrome dev summit 2015 Keynote
  • 49.
  • 50. Background Service WEB PUSH NOTIFICATION 필수 요소 Notification UI Push 등록/해지/이벤트
  • 51. Service Worker WEB PUSH NOTIFICATION 구성 Web Notification API Push API
  • 52. WEB PUSH = 구독 + 받기
  • 53. 4.0 Chrome 42+ 지원 브라우저.. Opera44
  • 55. Service Worker Client side proxy Written in Javascript Web Server Push Service SUBSCRIPTION ① ③ ④ ②
  • 56. WHAT! SUBSCRIPTION navigator.serviceWorker.ready.then(function(registration) {
 registration.pushManager.subscribe({userVisibleOnly: true}) .then(function(subscription) {
 // The push subscription details needed by the // application. server are now available, and can be // sent to it using, for example, an XMLHttpRequest. sendSubscriptionToServer(subscription);
 }), function(error) { // Subscription failed.
 }
 );
 });
  • 57. WHAT! SUBSCRIPTION navigator.serviceWorker.ready.then(function(registration) {
 registration.pushManager.subscribe({userVisibleOnly: true}) .then(function(subscription) {
 // The push subscription details needed by the application
 // server are now available, and can be sent to it using,
 // for example, an XMLHttpRequest. sendSubscriptionToServer(subscription);
 }), function(error) { // During development it often helps to log errors to the // console.
 }
 );
 }); { "name": "Simple Push Demo", "short_name": "Push Demo", "start_url": "/index.html?homescreen=1", "display": "standalone", "gcm_sender_id": "653317226796" } Define GCM Sender ID in Manifest.json
  • 58. Service Worker Background Service Web Server Push Service ① ② ③ ④
  • 59. RECEIVING A PUSH MESSAGE self.addEventListener('push', function(event) { event.waitUntil( fetch('/notification.json').then(function(response) { return response.json(); }).then(function(data) { return self.registration.showNotification(data.title, { body: data.body, icon: data.iconUrl, tag: data.tag, data: { url : data.url } }); }); ); });
  • 60. REFOCUS EXISTING WINDOWS self.addEventListener('notificationclick', function(event) { clients.matchAll({ type: 'window' }) .then(function(clients) { if (clients.length > 0) { clients[0].postMessage({ navigateTo: event.notification.data.url }); return clients[0].focus(); } else { return clients.openWindow(event.notification.data.url); } }) });
  • 61. Demo
  • 62.
  • 64. Service Worker Client side proxy Written in Javascript Web Server Push Service PAYLOAD DATA DATA DATA
  • 65. Q & A
  • 66. 참고자료 개념 이해 •Introduction to Service Worker •Service Worker - first draft published 표준 리소스 •Nightly API 사용 패턴 •The offline cookbook •플랫폼 구현자 참고 문서 •GitHub •Platinum Service Worker Elements •Service Worker API MDN