$30 off During Our Annual Pro Sale. View Details »
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Web notifications with Polymer & Firebase
Search
Filip Prochazka
November 26, 2016
Programming
0
79
Web notifications with Polymer & Firebase
Filip Prochazka
November 26, 2016
Tweet
Share
More Decks by Filip Prochazka
See All by Filip Prochazka
Firebase na webu? Hračka
filipproch
0
330
Web Notifications with Firebase
filipproch
0
82
Other Decks in Programming
See All in Programming
20251212 AI 時代的 Legacy Code 營救術 2025 WebConf
mouson
0
150
AIコーディングエージェント(Manus)
kondai24
0
180
チームをチームにするEM
hitode909
0
330
愛される翻訳の秘訣
kishikawakatsumi
3
320
Flutter On-device AI로 완성하는 오프라인 앱, 박제창 @DevFest INCHEON 2025
itsmedreamwalker
1
110
Findy AI+の開発、運用におけるMCP活用事例
starfish719
0
220
Go コードベースの構成と AI コンテキスト定義
andpad
0
120
配送計画の均等化機能を提供する取り組みについて(⽩⾦鉱業 Meetup Vol.21@六本⽊(数理最適化編))
izu_nori
0
150
tparseでgo testの出力を見やすくする
utgwkk
2
220
LLMで複雑な検索条件アセットから脱却する!! 生成的検索インタフェースの設計論
po3rin
3
720
手軽に積ん読を増やすには?/読みたい本と付き合うには?
o0h
PRO
1
170
エディターってAIで操作できるんだぜ
kis9a
0
720
Featured
See All Featured
Docker and Python
trallard
47
3.7k
Six Lessons from altMBA
skipperchong
29
4.1k
How GitHub (no longer) Works
holman
316
140k
How to Think Like a Performance Engineer
csswizardry
28
2.4k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
Automating Front-end Workflow
addyosmani
1371
200k
KATA
mclloyd
PRO
32
15k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
GitHub's CSS Performance
jonrohan
1032
470k
Art, The Web, and Tiny UX
lynnandtonic
303
21k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Writing Fast Ruby
sferik
630
62k
Transcript
with Polymer & Firebase Web notifications Filip Prochazka
• How far is the web? • Tools? • Notifications?
None
None
None
None
None
None
credit: Morgan Stanley
Users expect more!
None
None
None
We can do it
“I want to write least code possible” every developer ever
None
None
FCM
None
None
#UseThePlatform
<dom-module id="contact-card"> ... </dom-module>
<style>...</style> <template> <content></content> <iron-icon icon="star" hidden$="{{!starred}}"> </iron-icon> </template>
<script> Polymer({ is: 'contact-card', properties: { starred: Boolean } });
</script>
<contact-card starred> <img src="profile.jpg" alt="Eric's photo"> <span>Eric Bidelman</span> </contact-card
None
Polymer + Firebase = Polymerfire
<firebase-app auth-domain="mydb.firebaseapp.com" database-url="https://mydb.firebaseio.com/" api-key="AIzaSyDTP-eiQezleFsV2WdEzx_8v_g"> </firebase-app>
<firebase-auth id="auth" user="{{user}}" provider="google" on-error="handleError"> </firebase-auth> this.$.auth.signInWithPopup()
Web Notifications
<firebase-app auth-domain="mydb.firebaseapp.com" database-url="https://mydb.firebaseio.com/" api-key="AIzaSyDTP-eiQezleAhF_WEzx_8v_g" messaging-sender-id="811649979958"> </firebase-app>
<firebase-messaging id="messaging" token="{{token}}" on-message="_onMessageReceived"> </firebase-messaging>
<firebase-document path="/users/[[user.uid]]/token" value="[[token]]"> </firebase-document>
Service Worker
importScripts('../../firebase-app.js') importScripts('../../firebase-messaging.js') firebase.initializeApp({ messagingSenderId: '811649979958' }) var messaging = firebase.messaging()
messaging.setBackgroundMessageHandler( pushMessage => { ... })
const title = pushMessage.data.title const notificationOptions = { body: pushMessage.data.body,
icon: '/images/notification.png', tag: 'notification-tag', data: { targetUrl: pushMessage.data.targetUrl } }
self.registration .showNotification(title, notificationOptions)
self.addEventListener('notificationclick', event => { ... }
event.notification.close() var targetUrl = event.notification.data.targetUrl
event.waitUntil( clients.matchAll({ type: 'window', includeUncontrolled: !0 }).then( clientList => {
openWindow(clientList, targetUrl) }))
function openWindow(clientList, targetUrl) { clientList.forEach( client => { if (client.url.endsWith(targetUrl)
&& 'focus' in client) { return client.focus() } } return self.clients.openWindow(targetUrl) }
this.$.messaging.requestPermission() .then(() => { console.log('Notification permission granted.') }) .catch( err
=> { console.log('Notification permission was denied.') })
None
“What’s that?” your confused user
None
None
None
1. The web is important 2. Use the tools 3.
Think about the user
Filip Prochazka filipproch www.settleup.info