Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Firebase Realtime Database

Soham Mondal
November 09, 2016

Firebase Realtime Database

Slides from my talk on Firebase Realtime Database at Droidcon India 2016

Soham Mondal

November 09, 2016
Tweet

More Decks by Soham Mondal

Other Decks in Technology

Transcript

  1. @s0h4m [email protected] — Founder, Triveous — Creator, Voice Recorder —

    Google Expert, UX — Android/UX consultant — Organizer, Blrdroid — Mentor, Google Launchpad Accelerator Soham Mondal
  2. Firebase Realtime Database Agenda Introduction API Caveats and Alternatives —

    Introduction to the Firebase platform — Firebase Realtime Database — Realtime challenges — Use Case — Feature set — Getting Started — Read — Write — Value Event Listeners vs Child Event Listeners — Offline — Data structure — Query — Realtime + Admin API — Design patterns — Alternatives — Realm Mobile Platform/CouchDB/Others
  3. Book movies and pay onling Book Browse the latest movies

    Browse People should not stop using the app and keep using it do bookings Retention Increase engagement in consumers so they spend more time in the app Engagement
  4. Realtime Chat Talk to your friends and discuss the latest

    movies Realtime polling Poll on viewing the latest movies, the theatre, timing or even genre
  5. Updated Movie App Higher Engagement Retention Competitive Edge Benefits Book

    movies and pay onling Book Browse the latest movies Browse Poll on movies, shows and timings Poll Talk about the latest movies Talk
  6. — Server — Database — Realtime Updates — Synchronizing state

    — Client and server libraries — Offline The Realtime Collaborative Movie App
  7. Firebase Realtime Database — Hosted Json Database — Realtime Updates

    — Google Cloud — Scalable — Consistency — Offline — Speed — Good pricing — Cross platform support — Admin API — Firebase UI 11
  8. apply plugin: 'com.android.application' dependencies { // ... compile 'com.google.firebase:firebase-core:9.8.0' compile

    'com.google.firebase:firebase-database:9.8.0' } apply plugin: 'com.google.gms.google-services'
  9. FirebaseDatabase database = FirebaseDatabase.getInstance(); DatabaseReference myRef = database.getReference("message"); myRef.addValueEventListener(new ValueEventListener()

    { @Override public void onDataChange(DataSnapshot dataSnapshot) { } @Override public void onCancelled(DatabaseError error) { } });
  10. ChildEventListener childEventListener = new ChildEventListener() { @Override public void onChildAdded(DataSnapshot

    dataSnapshot, String previousChildName) {} @Override public void onChildChanged(DataSnapshot dataSnapshot, String previousChildName) {} @Override public void onChildRemoved(DataSnapshot dataSnapshot) { } @Override public void onChildMoved(DataSnapshot dataSnapshot, String previousChildName) {} @Override public void onCancelled(DatabaseError databaseError) {} }; myRef.addChildEventListener(childEventListener);
  11. { "chats": { "one": { "title": ”Soham Mondal", "messages": {

    "m1": { "sender": ”Soham", " Yes, let us definitely go ahead and book this otherwise…" }, "m2": { ... }, // a very long list of messages } }, "two": { ... } } }
  12. { "chats": { "one": { "title": ”Soham Mondal", "lastMessage": ”Yes,

    let us definitely go ahead and book this otherwise…", ”imageUrl": ”...", "timestamp": 1459361875666 }, "two": { ... }, "three": { ... } }, "members": { "one": { ”nidhi": true,
  13. "two": { ... }, "three": { ... } }, "messages":

    { "one": { "m1": { "name": ”soham", "message": ”ok what was that movie again", "timestamp": 1459361875337 }, "m2": { ... }, "m3": { ... } }, "two": { ... }, "three": { ... } } }
  14. START 2:15 pm App Open Send Message App goes into

    the background 3:00 pm App open New Message
  15. START 2:15 pm App Open Send Message App goes into

    the background 3:00 pm App open New Message
  16. START 2:15 pm App Open Send Message App goes into

    the background 3:00 pm App open New Message
  17. Caveats — Good but inflexible API — Search Query —

    Server side code — Migration — Limited use case — Play Services — Hosted
  18. Auxilliary Auxilliary Customer support Troubleshooting Core Core Features Chat application

    Cab booking service Module Modular Features Chat Polls, interaction
  19. Very popular with developers Launched recently Good offline db Excellent

    API Realm Open souce Reliable Android solution? Couch RethinkDB Gun Others Alternatives
  20. Altenatives Realm Mobile Platform Object database Native models Easy to

    use Great client side performance Better offline experience Built in encryption Advantages