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 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
AI Schema Enrichment for your Oracle AI Database
thatjeffsmith
0
290
CSC307 Lecture 09
javiergs
PRO
1
840
なるべく楽してバックエンドに型をつけたい!(楽とは言ってない)
hibiki_cube
0
140
それ、本当に安全? ファイルアップロードで見落としがちなセキュリティリスクと対策
penpeen
7
3.9k
コントリビューターによるDenoのすゝめ / Deno Recommendations by a Contributor
petamoriken
0
200
SourceGeneratorのススメ
htkym
0
200
フロントエンド開発の勘所 -複数事業を経験して見えた判断軸の違い-
heimusu
7
2.8k
CSC307 Lecture 05
javiergs
PRO
0
500
AI時代のキャリアプラン「技術の引力」からの脱出と「問い」へのいざない / tech-gravity
minodriven
21
7.3k
【卒業研究】会話ログ分析によるユーザーごとの関心に応じた話題提案手法
momok47
0
200
Grafana:建立系統全知視角的捷徑
blueswen
0
330
MDN Web Docs に日本語翻訳でコントリビュート
ohmori_yusuke
0
650
Featured
See All Featured
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.6k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7k
Testing 201, or: Great Expectations
jmmastey
46
8k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.4k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
590
The World Runs on Bad Software
bkeepers
PRO
72
12k
Designing for Performance
lara
610
70k
Building AI with AI
inesmontani
PRO
1
700
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
3.9k
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
100
Navigating Team Friction
lara
192
16k
How to build a perfect <img>
jonoalderson
1
4.9k
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