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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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で効率化できた業務・日常
ochtum
0
120
ローカルLLMを使ってB2Bサービスを作っていての学び
yaotti
0
160
Swiftのレキシカルスコープ管理
kntkymt
0
220
決定論的オーケストレーションの設計と実装 / Design and Implementation of Deterministic Orchestration
nrslib
3
1.3k
セキュリティの専門家じゃなくてもできる。「セキュリティ意識」をアップデートして サプライチェーン攻撃への耐性を高めよう。
tk3fftk
5
710
技術記事、AIに書かせるか、自分で書くか? 〜それでも私が自分の手で書く理由〜 / #QiitaConference
jnchito
2
1.4k
Why Laravel apps break—Mastering the fundamentals to keep them maintainable
kentaroutakeda
1
350
net-httpのHTTP/2対応について
naruse
0
470
Old Dog, New Tricks: The Java 25 Reinvention - JNation
bazlur_rahman
0
150
Claspは野良GASの夢をみるか
takter00
0
180
ADKを使って簡単にAIエージェントを作ってみよう
k1mu21
0
250
Java × distroless で 軽量なコンテナイメージを / Java on Distroless
contour_gara
0
520
Featured
See All Featured
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
280
The #1 spot is gone: here's how to win anyway
tamaranovitovic
2
1.1k
GraphQLとの向き合い方2022年版
quramy
50
15k
My Coaching Mixtape
mlcsv
0
140
エンジニアに許された特別な時間の終わり
watany
107
250k
Mobile First: as difficult as doing things right
swwweet
225
10k
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
290
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
610
Context Engineering - Making Every Token Count
addyosmani
9
960
Odyssey Design
rkendrick25
PRO
2
690
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
62
44k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
201
75k
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