Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Web push notifications
Search
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
書籍「プロフェッショナルAI駆動開発」紹介スライド
juntaromatsumoto
0
260
言葉の格闘技のススメ~紙とペンと言葉から始める、キャリアの描き方~
progresscicada
2
170
GDG Korea Android: 2026 I/O Extended ~ What's new in Android development tools
pluu
0
240
Building a Meta Ray-Ban display app
akkeylab
0
170
Gmail/Google DriveをトリガーにAIエージェントを動かそう! / Run AI agents with Gmail/Google Drive as triggers!
har1101
2
360
楽しそうなつよつよエンジニアと目が死んでる僕/A brilliant engineer having a blast, and dead-eyed me.
3l4l5
2
230
AWS DevOps AgentのAzure接続機能を検証して見えた活用法/Use Cases Verified for the AWS DevOps Agent's Azure Connectivity Feature
masakiokuda
1
260
仕様書を書く前にハーネスを作る - Agent Native開発は「探索を速く、判定を固く」
gotalab555
4
1.7k
ここ半年くらいでAIに作らせたR用ツール
eitsupi
0
400
What's New in Android 2026
veronikapj
0
270
My Marp Sample
sinoue0108
0
100
FDEが実現するAI駆動経営の現在地
gonta
2
290
Featured
See All Featured
Art, The Web, and Tiny UX
lynnandtonic
304
22k
Optimizing for Happiness
mojombo
378
71k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.8k
Practical Orchestrator
shlominoach
191
12k
Building AI with AI
inesmontani
PRO
1
1.1k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.4k
Navigating Team Friction
lara
192
16k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.1k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
250
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
73
41k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
Being A Developer After 40
akosma
91
590k
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