5. Real time database
● NoSQL, JSON database
● Maps each piece of data to a URL
● Pushes updates in milliseconds
when things change
6. ● seemless offline support
● automatic sync on network
acccess
Offline support
7. ● Automatically syncs to
the server and pushes
to other devices when
network comes back
Offline support
8. Drop-in support for login with
● Email & Password
● Common OAuth providers
○ Google
○ Facebook
○ Twitter
○ Github
● Your own custom auth tokens
Auth and user management
9. 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
10. Security Considerations
● Namespace sandboxing
● HTTPS + 2048-bit SSL
● BCrypt for passwords (not stored directly in the
Firebase)
● Security rules stored and executed server side
11. 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
13. 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);
}
14. 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");
15. ● 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
16. 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());
}
});
17. 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);