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

Introduction to Firebase by Igor Flysta

Introduction to Firebase by Igor Flysta

Introduction to Firebase by Igor Flysta

GDG Ternopil

August 19, 2015
Tweet

More Decks by GDG Ternopil

Other Decks in Programming

Transcript

  1. REALTIME DATABASE • NoSQL JSON data-store • Cross-platform client-side SDKs

    • Offline out-of-the-box • Auto-scaling • RESTful API
  2. REALTIME DATA Whenever data is updated in Firebase, it sends

    the update down to every listening client
  3. Sync Data Firebase ref = new Firebase (“https://<your-firebase-app>.firebaseio.com/message”); ref.addValueEventListener(new ValueEventListener()

    { @Override public void onDataChange(DataSnapshop snapshot) { System.out.println(snapshot.getValue()); } @Override public void onCancelled(FirebaseError error) { } });
  4. { "messages": { "message1": { "text": "Hello, world", "country": "USA"

    }, "message2": { "text": "Bonjour monde", "country": "France" }, "message3": { "text": "Hello, world", "country": "England" }, "message4": { "text": "你好世界", "country": "China" }, "message5": { "text": "γειά σου κόσμος", "country": "Greece" }, ... } }
  5. Intermittent Offline What happens when you go through a tunnel?

    Firebase clients store a local cache of your data. When the user goes offline, the app still works as expected with the local cache.
  6. Extended Offline What happens when you go on a flight?

    On mobile, Firebase persists data to a local store. The app will continue to work even across app restarts.
  7. Autentification • Email & Password • Google • Twitter •

    Facebook • Github • Anonymous • Custom
  8. Autentification ref.authWithOAuthToken("google", "<OAuth Token>", new Firebase. AuthResultHandler() { @Override public

    void onAuthenticated(AuthData authData) { // the Google user is now authenticated with your Firebase app } @Override public void onAuthenticationError(FirebaseError firebaseError) { // there was an error } });
  9. Security • Declarative rules language • JavaScript-like syntax • Executed

    server-side • Authorization • Schema validation
  10. Security By default everyone can write and read { "rules":

    { ".read": true, ".write": true, } }
  11. Security Everyone can read, but no one can write {

    "rules": { ".read": true, ".write": false, } }
  12. Security Secure specific parts of your Firebase { "rules": {

    ".read": true, "message": { ".write": false } } }
  13. Security Special variables to power autentification { "rules": { ".read":

    true, "message": { ".write": "auth !== null", ".validate": "newData.isString() && newData.val().length < 100" } } }
  14. User-based Security Use $wildcards as route parameters { "rules": {

    ".read": false, ".write": false, "users": { "$userid": { ".read": "true", ".write": "auth.uid === $userid" } } } }
  15. Hosting • Free static asset hosting • SSL certificate •

    Global CDN • Single command deploys • One-click rollbacks • Custom domains
  16. And More ... • Angular, React, Ember, Backbone bindings •

    GeoFire (realtime geolocation) • Firepad (realtime text editing) • Open Data Sets • More coming soon...