Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Post IO Meetup
Introduction to Firebase
Amrit Sanjeev
Organizer, Blrdroid
Who am I ?
What is firebase
Realtime Database User Management Hosting
Realtime Application Platform
Real time database
● NoSQL, JSON database
● Maps each piece of data to a URL
● Pushes updates in milliseconds
when things ...
● seemless offline support
● automatic sync on network
acccess
Offline support
● Automatically syncs to
the server and pushes
to other devices when
network comes back
Offline support
Drop-in support for login with
● Email & Password
● Common OAuth providers
○ Google
○ Facebook
○ Twitter
○ Github
● Your o...
Static hosting
Production grade static-asset hosting service
● SSL Certificate included!
● Backed by a global CDN
● Launch...
Security Considerations
● Namespace sandboxing
● HTTPS + 2048-bit SSL
● BCrypt for passwords (not stored directly in the
F...
Reliability and Data retention
● SLA is 99.95%
● Check on status.firebase.com
● Consistency model guarantees write persist...
Now let’s find out
how much code it is to
implement
Add firebase support
In build.gradle
dependencies {
compile 'com.firebase:firebase-client-android:2.3.0+'
}
In Android man...
Data store
Creating a reference
Firebase rootRef = new Firebase("https://docs-examples.firebaseio.com/web/data");
Directly...
● setValue( ) Write or replace data to a defined path, like messages/users/<username>
● updateChildren( ) Update some of t...
Retrieving data
● Attach an asynchronous listener to a Firebase reference.
● The listener will be triggered
○ once for the...
Offline support
Adding offline support
Firebase.getDefaultConfig().setPersistenceEnabled(true);
Keeping data refresh
Fireb...
Thank you!
Amrit Sanjeev
@amsanjeev
www.blrdroid.org
Introduction to Firebase on Android
Upcoming SlideShare
Loading in …5
×

Introduction to Firebase on Android

5,262 views

Published on

Simple introduction to Firebase.

Published in: Technology
  • Login to see the comments

Introduction to Firebase on Android

  1. 1. Post IO Meetup Introduction to Firebase Amrit Sanjeev Organizer, Blrdroid
  2. 2. Who am I ?
  3. 3. What is firebase Realtime Database User Management Hosting Realtime Application Platform
  4. 4. Real time database ● NoSQL, JSON database ● Maps each piece of data to a URL ● Pushes updates in milliseconds when things change
  5. 5. ● seemless offline support ● automatic sync on network acccess Offline support
  6. 6. ● Automatically syncs to the server and pushes to other devices when network comes back Offline support
  7. 7. Drop-in support for login with ● Email & Password ● Common OAuth providers ○ Google ○ Facebook ○ Twitter ○ Github ● Your own custom auth tokens Auth and user management
  8. 8. Static hosting Production grade static-asset hosting service ● SSL Certificate included! ● Backed by a global CDN ● Launch with: firebase deploy ● One click rollbacks from our dashboard
  9. 9. Security Considerations ● Namespace sandboxing ● HTTPS + 2048-bit SSL ● BCrypt for passwords (not stored directly in the Firebase) ● Security rules stored and executed server side
  10. 10. Reliability and Data retention ● SLA is 99.95% ● Check on status.firebase.com ● Consistency model guarantees write persistence ● Three tiered backups, every 24 hours ● Private customer backup to GCS/S3
  11. 11. Now let’s find out how much code it is to implement
  12. 12. Add firebase support In build.gradle dependencies { compile 'com.firebase:firebase-client-android:2.3.0+' } In Android manifest <uses-permission android:name="android.permission.INTERNET" /> In Android application or activity @Override public void onCreate() { super.onCreate(); Firebase.setAndroidContext(this); }
  13. 13. Data store Creating a reference Firebase rootRef = new Firebase("https://docs-examples.firebaseio.com/web/data"); Directly access child nodes in the data Firebase rootRef = new Firebase("https://docs-examples.firebaseio.com/web/data/users/mchen/name"); Using the Child() api call Firebase rootRef = new Firebase("https://docs-examples.firebaseio.com/web/data"); rootRef.child("users/mchen/name");
  14. 14. ● setValue( ) Write or replace data to a defined path, like messages/users/<username> ● updateChildren( ) Update some of the keys for a defined path without replacing all of the data ● push( ) Add to a list of data in your Firebase database. ● runTransaction( ) Use our transactions feature when working with complex data Firebase usersRef = ref.child("users"); Map<String, User> users = new HashMap<String, User>(); users.put("alanisawesome", alanisawesome); users.put("gracehop", gracehop); usersRef.setValue(users); Saving data
  15. 15. Retrieving data ● Attach an asynchronous listener to a Firebase reference. ● The listener will be triggered ○ once for the initial state of the data ○ again anytime the data changes Firebase ref = new Firebase("https://docs-examples.firebaseio.com/web/saving-data/fireblog/posts"); ref.addValueEventListener(new ValueEventListener() { @Override public void onDataChange(DataSnapshot snapshot) { System.out.println(snapshot.getValue()); } @Override public void onCancelled(FirebaseError firebaseError) { System.out.println("The read failed: " + firebaseError.getMessage()); } });
  16. 16. Offline support Adding offline support Firebase.getDefaultConfig().setPersistenceEnabled(true); Keeping data refresh Firebase scoresRef = new Firebase("https://dinosaur-facts.firebaseio.com/scores"); scoresRef.keepSynced(true);
  17. 17. Thank you! Amrit Sanjeev @amsanjeev www.blrdroid.org

×