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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Diego Gurgel
July 02, 2017
Programming
51
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Web push notifications
Diego Gurgel
July 02, 2017
Transcript
13 slides
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
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
Stage 3でも仕様は変わる。アプリケーション開発者のためのTC39プロセスの読み方
bicstone
1
610
JavaScriptはシングルバイナリの夢を見るか / Does JavaScript Dream of a Single Binary?
ssssota
0
700
ruby/uri meets WHATWG
jinroq
0
160
imagewebp()の向こう側: WebPはなぜ JPEG・PNGより軽いのか
yuzneri
0
150
AIエージェントの「テストは通るのに本番で壊れる」を減らす
shibuiwilliam
3
130
Lean で手続き的プログラム の証明が書けるようになった
inoueasei
9
4.9k
Agentic AI with the Power of Jakarta EE
ivargrimstad
0
230
Growing PicoRuby's Ecosystem on ESP32
yuuu
2
150
AWS CDKを理解するために公式の定義を深掘って解説してみる / Understanding AWS CDK by Digging into Its Official Definition
akihisaikeda
3
350
正解の無い問題を 「できるだけ上手く」解く ヒューリスティックで感性を磨こう。〜現実課題をプログラミングで解きあうコミュニティについて〜
allegrogiken
0
120
The Cost of the DOM
ypresto
2
670
Engineering Biometric UX Across Android Versions | DroidKnights 2026
ryunen344
1
220
Featured
See All Featured
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
540
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
1k
Building Adaptive Systems
keathley
44
3.3k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.7k
Everyday Curiosity
cassininazir
0
420
The Mindset for Success: Future Career Progression
greggifford
PRO
0
570
Claude Code のすすめ
schroneko
67
230k
Scaling GitHub
holman
464
140k
Information Architects: The Missing Link in Design Systems
soysaucechin
1
1.3k
New Earth Scene 8
popppiees
5
2.9k
Heart Work Chapter 1 - Part 1
lfama
PRO
11
37k
Making Projects Easy
brettharned
120
6.9k