26. Confidential & ProprietaryGoogle Cloud Platform 26
Google Authentication
mFirebaseRef.authWithOAuthToken("google", authToken, new
Firebase.AuthResultHandler() {
@Override
public void onAuthenticated(AuthData authData) {
Log.v(TAG, "Auth success");
}
@Override
public void onAuthenticationError(FirebaseError firebaseError) {
Toast.makeText(getApplicationContext(),
"Auth failed. Please try again",
Toast.LENGTH_SHORT).show();
}
});
27. Confidential & ProprietaryGoogle Cloud Platform 27
Offline
var amOnline = new Firebase('https://<YOUR-FIREBASE>.firebaseio.com/.
info/connected');
var presenceRef = new Firebase('https://<YOUR-FIREBASE>.firebaseio.
com/presence/'
+ userid);
amOnline.on('value', function(value) {
if (value.val() === true) {
// Connected (or reconnected)!
presenceRef.onDisconnect().set(false); // one off, has to be reregistered
presenceRef.set(true);
}
});
28. Confidential & ProprietaryGoogle Cloud Platform 28
Reading Data
Firebase ref = new Firebase("https://<your-firebase>.firebaseio.com");
ref.child("background").addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
System.out.println(dataSnapshot.getValue()); // prints “grid”
}
@Override public void onCancelled(FirebaseError error) { }
});
29. Confidential & ProprietaryGoogle Cloud Platform 29
Reading Data
Firebase ref = new Firebase("https://<your-firebase>.firebaseio.com");
ref.child("background").addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
System.out.println(dataSnapshot.getValue()); // prints “grid”
}
...
});
30. Confidential & ProprietaryGoogle Cloud Platform 30
Writing Data
Firebase ref = new Firebase("https://<your-firebase>.firebaseio.com");
ref.child("background").setValue("grid");
37. Confidential & ProprietaryGoogle Cloud Platform 37
Twitch.tv is the world's
leading video platform
and community for
gamers, and uses
Firebase to notify
users when a realtime
stream goes live.
38. Confidential & ProprietaryGoogle Cloud Platform 38
Where we used to
spend 50% of our
development time
building the backend,
we can focus now
95% of our time on the
actual application.
“
”