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
社内規程RAGの精度を73.3% → 100%に改善した話
oharu121
13
8.2k
米国のサイバーセキュリティタイムラインと見る Goの暗号パッケージの進化
tomtwinkle
2
610
CDIの誤解しがちな仕様とその対処TIPS
futokiyo
0
220
RAGでハマりがちな"Excelの罠"を、データの構造化で突破する
harumiweb
9
2.9k
LangChain4jとは一味違うLangChain4j-CDI
kazumura
1
200
Angular-Apps smarter machen mit Gen AI: Lokal und offlinefähig - Hands-on Workshop!
christianliebel
PRO
0
120
go directiveを最新にしすぎないで欲しい話──あるいは、Go 1.26からgo mod initで作られるgo directiveの値が変わる話 / Go 1.26 リリースパーティ
arthur1
2
570
脱 雰囲気実装!AgentCoreを良い感じにWEBアプリケーションに組み込むために
takuyay0ne
3
290
PHPのバージョンアップ時にも役立ったAST(2026年版)
matsuo_atsushi
0
140
Agentic AI: Evolution oder Revolution
mobilelarson
PRO
0
190
モックわからないマン卒業記 ~振る舞いを起点に見直した、フロントエンドテストにおけるモックの使いどころ~
tasukuwatanabe
3
390
Codexに役割を持たせる 他のAIエージェントと組み合わせる実務Tips
o8n
4
1.4k
Featured
See All Featured
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2k
Bash Introduction
62gerente
615
210k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
60
43k
GraphQLとの向き合い方2022年版
quramy
50
14k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
150
Java REST API Framework Comparison - PWX 2021
mraible
34
9.2k
Thoughts on Productivity
jonyablonski
75
5.1k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.5k
Raft: Consensus for Rubyists
vanstee
141
7.4k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
150
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
1
160
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