Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Web push notifications
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Diego Gurgel
July 02, 2017
Programming
49
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Web push notifications
Diego Gurgel
July 02, 2017
More Decks by Diego Gurgel
See All by Diego Gurgel
Facilitando suas atividades com ferramentas online
diegogurgel
0
130
Other Decks in Programming
See All in Programming
re:Inventに行く前に知っておきたい現地参加のノウハウ
nokomoro3
0
400
ジョジョの世界をXRで再現する
mofurune
0
150
複雑なUIコンポーネントとの ⻑い付き合い⽅:波及するバグからテスト戦略を経て、安全な再設計へ
mixplace
0
380
phperだってパンチカードでコーディングしたい
o0h
PRO
0
280
KiroのSpecで「五目並べ」を作ってみる
satoshi256kbyte
1
370
CodeRabbitの効果検証と過ごしてみた3ヶ月
armondando
0
230
動作中のプログラムの中身をリアルタイムに覗く / Realtime Debugger for CSharp with Roslyn
prota
1
1.8k
UPDATE をやめる — EF Core でマスタをバージョン管理する
panda728
PRO
0
1.2k
個人開発者よ、Honoを使え(おじさんver)
tanahiro2010
2
250
SalesForceを内製化!? ~ HR事業を支える顧客管理基盤のインフラを大公開 ~
oku053
0
170
カツオ、ご期待ください
suneo3476
0
170
コードレビューのボトルネックを"する側"と"される側"の両面から解消する
yub0n
2
1.6k
Featured
See All Featured
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.5k
Building an army of robots
kneath
307
47k
Building the Perfect Custom Keyboard
takai
2
900
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1.1k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
Designing for humans not robots
tammielis
254
26k
The World Runs on Bad Software
bkeepers
PRO
72
12k
The SEO identity crisis: Don't let AI make you average
varn
0
590
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
330
Designing Dashboards & Data Visualisations in Web Apps
destraynor
232
55k
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.6k
Everyday Curiosity
cassininazir
0
350
Transcript
Web push notifications @d_gurgel
Å Visitas únicas 12,500 3,800 Visitas únicas mensais Fonte: comScore
Mobile Metrix, U.S., Age 18+
No Sebrae
Como funciona? ⚙ ☁ Cliente Servidor
Como funciona no cliente? ☁ Permissão do usuário Inscrição Enviar
inscrição
if ('serviceWorker' in navigator) { navigator.serviceWorker.register('sw.js') .then(initialState); }else { console.log(':(');
} navigator.serviceWorker.ready.then(swRegistration=>{ return swRegistration.pushManager .subscribe({userVisibleOnly:true}); }).then(subscription=>{ console.log(subscription); /*Enviar para o servidor*/ }); ☁ "gcm_sender_id": "827747435376" Notification.requestPermission().then(status)
E no servidor? ☁ Seu servidor Push Service ⬇ ⬇
const webpush = require('web-push'); const vapidKeys = webpush.generateVAPIDKeys(); webpush.setGCMAPIKey('GCMKEY'); webpush.setVapidDetails(
'mailto:
[email protected]
', vapidKeys.publicKey, vapidKeys.privateKey ); const pushSubscription = { endpoint:”https://android.googleapis.com/gcm/send/ewcFEKglM…”, keys:{ p256dh:”BERT29SHqILHUjCaeN8NJMRXL8oQSQs…”, auth:"gzOk5sX1HTtfXb4PmVoiFA==" } } ☁ const payload = { title: 'Frontend meetup', message: ':) ', };
webpush.sendNotification(pushSubscription, JSON.stringify(payload)) .then(data=>{ console.log(data); }) .catch(err=>{ console.log(err); });
⚙ 'use strict'; self.addEventListener('push', function(event) { let data = event.data.json();
event.waitUntil( self.registration.showNotification(data.title, { body: data.message, }) ); });
UX ⌚
UX 0
None