Chat Done Right!
With Android & Firebase
How is this going to work?
This is NOT a lecture…
‣ Interactive discussion
‣ There is no “questions” slide
Our Tools
Android
Kotlin
Firebase
Realtime Database
Cloud Functions
Database Rules
What we’re building
A chat app (surprise) that needs:
1. Authentication
2. Users
3. To send messages
4. To show active chats
5. A contact list
6. Send notifications
7. Group management
Why Firebase?
Realtime
Database
Serverless
Cloud Functions
Seamless
Synchronisation
Realtime
Notifications
Native SDKs
Our Tools
Android
Kotlin
Firebase
Realtime Database
Cloud Functions
Database Rules
Write directly to DB from Android
๏ CRUD - You can do just about anything from the client
๏ Persistence and caching to writes to DB
๏ Super super fast
๏ But the are somethings better done with a Cloud Function
Database Rules
Insecure rules
(public access)
Default rules
(read/write if authorised)
All Messages
chat_id_1 chat_id_2
message_id_1
message_id_2
message_id_3
message_id_4
All Chat Previews
user_uid_1 user_uid_2
chat_id_1
chat_id_2
All Chat Previews
user_uid_1 user_uid_2
chat_id_1
chat_id_2 But how do we know which
chat previews to update
when a message is sent?
Chat Done Right
Chat Done Right
But wait, there is!
๏ Unnecessary logic on client apps
๏ Direct write access to DB
๏ Security rules management easily
becomes a nightmare
Introducing Cloud Functions
๏ Conditional triggering & throttling
‣ On node changes (has auth object)
‣ Client SDK callable (has auth object)
‣ HTTP Request
๏ Central & Secure
๏ Node.js
๏ Logging
๏ Admin rights on all operations
Chat Done Right
Calling a function
Cloud FunctionAndroid App
https://tinyurl.com/chitchatCloud
https://tinyurl.com/chitchatAndroid
Chat Done Right
Chat Done Right:
Using Cloud Functions
Trigger onWriteSend message
payload
onSendMessage
Function
Realtime DatabaseAndroid App
User 1
Why the direct write
๏ Caches the write (local state management)
๏ Avoid response delay
But!
๏ Write access risks
Solution
Only allow message creates (not updates) for
chats that an authorised user is part of.
Remember these
Insecure rules
(public access)
Default rules
(read/write if authorised)
Database Rules
Adding security: Taking it up a notch
Trigger onWriteSend message
payload
onSendMessage
Function
Realtime DatabaseAndroid App
User 1
Using Cloud Functions
for Chat
onSendMessage
Function
Chat Members
Node
Fetch
Chat Member
IDs
Write to each
Chat Preview
Chat Preview
Node
Using Cloud Functions
for Chat
Android Apps
User 1 User 2 User 3
All user
Chat previews
Updated
Chat Preview
Node
Notifications sent
Take Homes
•Cloud functions takes logic off the client
• This avoids repetition between the
platforms
• Easier to think about security
• If you can use a Cloud Function do it
•Writing directly to DB from client
• Firebase handles the persistence
• Caches writes & reads
wisani@nona.digital
adrian@nona.digital
https://tinyurl.com/chitchatCloud
https://tinyurl.com/chitchatAndroid

More Related Content

PDF
OneLogin qpstudy_20160716
PDF
Function of OneLogin
PPTX
Microservices in GO lang
PDF
Javantura v4 - True RESTful Java Web Services with JSON API and Katharsis - M...
PDF
O365Con18 - Connect SharePoint Framework Solutions to API's secured with Azur...
PPTX
.NET Fest 2017. Денис Резник. Исполнение Запроса в SQL Server. Ожидание - Реа...
PPTX
Timings API: Performance Assertion during the functional testing
PPTX
.NET Fest 2017. Андрей Антиликаторов. Проектирование и разработка приложений ...
OneLogin qpstudy_20160716
Function of OneLogin
Microservices in GO lang
Javantura v4 - True RESTful Java Web Services with JSON API and Katharsis - M...
O365Con18 - Connect SharePoint Framework Solutions to API's secured with Azur...
.NET Fest 2017. Денис Резник. Исполнение Запроса в SQL Server. Ожидание - Реа...
Timings API: Performance Assertion during the functional testing
.NET Fest 2017. Андрей Антиликаторов. Проектирование и разработка приложений ...

What's hot (20)

PDF
London Non-Profit Spring 22 Salesforce Release
PDF
Microservices: a journey of an eternal improvement
PDF
London Salesforce Developer January 2022
PDF
70-534: ARCHITECTING MICROSOFT AZURE SOLUTIONS
PPTX
Rest api with node js and express
PDF
Microservice Secrets
PDF
What’s new in WSO2 Enterprise Integrator 6.6
PPTX
MongoDB World 2018: Evolving your Data Access with MongoDB Stitch
PPTX
Code Generation for Azure with .net
PDF
Javantura v4 - Test-driven documentation with Spring REST Docs - Danijel Mitar
PDF
Introduction to Firebase on Android
PPTX
API Versioning in the Cloud
PDF
Design Microservice Architectures the Right Way
PPTX
Serverless Computing With Azure Functions
PPTX
Progressive Web Application - Advanced Topics
PPTX
Architecture in real
PDF
Production - Designing for Testability
PDF
O365Con18 - Automate your Tasks through Azure Functions - Elio Struyf
PDF
Mobile Authentication for iOS Applications - Stormpath 101
PPTX
Progressive Web Apps
London Non-Profit Spring 22 Salesforce Release
Microservices: a journey of an eternal improvement
London Salesforce Developer January 2022
70-534: ARCHITECTING MICROSOFT AZURE SOLUTIONS
Rest api with node js and express
Microservice Secrets
What’s new in WSO2 Enterprise Integrator 6.6
MongoDB World 2018: Evolving your Data Access with MongoDB Stitch
Code Generation for Azure with .net
Javantura v4 - Test-driven documentation with Spring REST Docs - Danijel Mitar
Introduction to Firebase on Android
API Versioning in the Cloud
Design Microservice Architectures the Right Way
Serverless Computing With Azure Functions
Progressive Web Application - Advanced Topics
Architecture in real
Production - Designing for Testability
O365Con18 - Automate your Tasks through Azure Functions - Elio Struyf
Mobile Authentication for iOS Applications - Stormpath 101
Progressive Web Apps
Ad

Similar to Chat Done Right (20)

POTX
devworkshop-10_28_1015-amazon-conference-presentation
PDF
Serverless Design Patterns (London Dev Community)
PPS
Getting Started With Android Application Development [IndicThreads Mobile Ap...
PPT
CFInterop
PPTX
Android Whats running in background
PDF
Serverless Design Patterns
PPTX
MongoDB World 2018: Ch-Ch-Ch-Ch-Changes: Taking Your Stitch Application to th...
PDF
Andy Malone - The new office 365 for it pro's
PDF
NoSQLEU: Different NoSQL tools in Production
PDF
Serveless design patterns
PPTX
Why And When Should We Consider Stream Processing In Our Solutions Teqnation ...
PDF
Office 365 introduction and technical overview
PPTX
Develop Hybrid Mobile Application with Azure Mobile Services and Telerik Plat...
PPTX
Meet with Meteor
PPTX
Internet of Things and Edge Compute at Chick-fil-A
PDF
Behat internals for advanced usage. Symfony Camp 2016
PPTX
The dev ops code has no servers
PPTX
Cloud Native 오픈소스 서비스 소개 및 Serverless로 실제 게임 개발하기
PDF
"Micro-frontends from A to Z. How and Why we use Micro-frontends in Namecheap...
PPTX
Top Java Performance Problems and Metrics To Check in Your Pipeline
devworkshop-10_28_1015-amazon-conference-presentation
Serverless Design Patterns (London Dev Community)
Getting Started With Android Application Development [IndicThreads Mobile Ap...
CFInterop
Android Whats running in background
Serverless Design Patterns
MongoDB World 2018: Ch-Ch-Ch-Ch-Changes: Taking Your Stitch Application to th...
Andy Malone - The new office 365 for it pro's
NoSQLEU: Different NoSQL tools in Production
Serveless design patterns
Why And When Should We Consider Stream Processing In Our Solutions Teqnation ...
Office 365 introduction and technical overview
Develop Hybrid Mobile Application with Azure Mobile Services and Telerik Plat...
Meet with Meteor
Internet of Things and Edge Compute at Chick-fil-A
Behat internals for advanced usage. Symfony Camp 2016
The dev ops code has no servers
Cloud Native 오픈소스 서비스 소개 및 Serverless로 실제 게임 개발하기
"Micro-frontends from A to Z. How and Why we use Micro-frontends in Namecheap...
Top Java Performance Problems and Metrics To Check in Your Pipeline
Ad

Recently uploaded (20)

PDF
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
PPTX
Custom Battery Pack Design Considerations for Performance and Safety
PDF
Produktkatalog für HOBO Datenlogger, Wetterstationen, Sensoren, Software und ...
PPTX
Modernising the Digital Integration Hub
PDF
OpenACC and Open Hackathons Monthly Highlights July 2025
PDF
sbt 2.0: go big (Scala Days 2025 edition)
PPTX
GROUP4NURSINGINFORMATICSREPORT-2 PRESENTATION
PPT
Module 1.ppt Iot fundamentals and Architecture
PDF
STKI Israel Market Study 2025 version august
PPTX
2018-HIPAA-Renewal-Training for executives
PDF
Zenith AI: Advanced Artificial Intelligence
PPTX
Configure Apache Mutual Authentication
PDF
Getting started with AI Agents and Multi-Agent Systems
PDF
Consumable AI The What, Why & How for Small Teams.pdf
PDF
A proposed approach for plagiarism detection in Myanmar Unicode text
PPTX
AI IN MARKETING- PRESENTED BY ANWAR KABIR 1st June 2025.pptx
PPTX
Chapter 5: Probability Theory and Statistics
PDF
A contest of sentiment analysis: k-nearest neighbor versus neural network
PDF
Enhancing plagiarism detection using data pre-processing and machine learning...
DOCX
search engine optimization ppt fir known well about this
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
Custom Battery Pack Design Considerations for Performance and Safety
Produktkatalog für HOBO Datenlogger, Wetterstationen, Sensoren, Software und ...
Modernising the Digital Integration Hub
OpenACC and Open Hackathons Monthly Highlights July 2025
sbt 2.0: go big (Scala Days 2025 edition)
GROUP4NURSINGINFORMATICSREPORT-2 PRESENTATION
Module 1.ppt Iot fundamentals and Architecture
STKI Israel Market Study 2025 version august
2018-HIPAA-Renewal-Training for executives
Zenith AI: Advanced Artificial Intelligence
Configure Apache Mutual Authentication
Getting started with AI Agents and Multi-Agent Systems
Consumable AI The What, Why & How for Small Teams.pdf
A proposed approach for plagiarism detection in Myanmar Unicode text
AI IN MARKETING- PRESENTED BY ANWAR KABIR 1st June 2025.pptx
Chapter 5: Probability Theory and Statistics
A contest of sentiment analysis: k-nearest neighbor versus neural network
Enhancing plagiarism detection using data pre-processing and machine learning...
search engine optimization ppt fir known well about this

Chat Done Right