+ All Categories
Home > Software > Introduction to Firebase with Android and Beyond...

Introduction to Firebase with Android and Beyond...

Date post: 16-Apr-2017
Category:
Upload: kasper-loevborg-jensen
View: 524 times
Download: 1 times
Share this document with a friend
72
Kasper Løvborg Jensen Leafcastle Labs | Aarhus University Introduction to Firebase With Android and Beyond… Kasper Løvborg Jensen
Transcript
Page 1: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Introduction to Firebase With Android and Beyond…

Kasper Løvborg Jensen

Page 2: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Kasper Løvborg Jensen

Chief Wizard, Founder Leafcastle Labs Associate Professor Aarhus University School of Engineering Lead / Lab Commander ORBIT Lab Organizer Google Developer Group Aarhus @KasperLJ [email protected]

Page 3: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

β

Page 4: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Outline

•  Introduction – What is Firebase? – What can I use it for? – How do I get started?

•  Tech demos/hacks – Android –  IoT devices – Web

•  Discussion

Page 5: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Firebase

“Firebase is a fully managed platform for building iOS, Android, and web apps that provides automatic data synchronization, authentication services, messaging, file storage, analytics, and more. Starting with Firebase is an efficient way to build or prototype mobile backend services”

https://cloud.google.com/solutions/mobile/mobile-app-backend-services#firebase

Page 6: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Page 7: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Philosophy

1.  Cross platform 2.  Developer experience 3.  Integrations

</> ++ $

Develop Grow Earn

https://firebase.google.com/

Page 8: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Cross Platform

•  Android •  iOS •  Web •  Cloud •  IoT •  …

Page 9: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

https://firebase.google.com/

Page 10: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Core Features: Development •  Real-time Database •  Storage •  Authentication •  Remote Configuration •  Cloud Messaging •  Hosting •  Analytics •  Crash Reporting •  Testing / Cloud Test Lab

https://console.firebase.google.com

Page 11: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Authentication

Page 12: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Authentication

https://firebase.google.com/docs/auth/

Page 13: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Authentication

•  Flexible – Email/password – Google, Facebook, Twitter, GitHub – Custom – Anonymous / temp

•  Standardized – Oauth 2.0 – OpenID Connect

Page 14: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Database

Page 15: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Firebase Realtime Database

•  Cloud based, NoSQL •  Offline mode •  Synchs in realtime with clients •  Store data/objects as JSON •  Security Rules for security and data

validation

Page 16: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Storage

Page 17: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Firebase Storage

•  Files – Photos, audio, video, etc.

•  Handles upload – Security and robustness

•  Based on Google Cloud Storage – Highly scalable – Sharable with GCP services

•  Integrates with Firebase Authentication

Page 18: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Hosting

Page 19: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Hosting

•  Static web content •  CLI tools for easy setup and deployment •  Free SSL build in •  CDN for global delivery •  Versioning and roll-backs •  Hosted at *.firebaseapp.com – Can transition to custom domain

Page 20: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

CLI for hosting

Page 21: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Remote Config

Page 22: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Remote Config

•  Instrument your app and set up server – Key-value pairs – Rules

•  Quick updates •  Feature toggling •  A/B testing

https://firebase.google.com/

Page 23: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Test Lab

Page 24: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Test Lab •  Cloud based test infrastructure for real

devices •  Run test on configuration matrix and get

results: logs, video, screen dumps •  Supports: Espresso, Robotium, …

https://firebase.google.com/docs/test-lab/

Page 25: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Crash Reports

Page 26: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Crash Reports

•  Log details on crashes on Android and iOS

Source: Google

Page 27: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Analytics

Page 28: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Analytics •  Powerful built-in Analytics – Automatically captured data – Custom events

•  Define audience and segment analysis •  Integrates across services

Source: Google

Page 29: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Cloud Messaging and Notifications

Page 30: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Cloud Messaging •  Firebase Cloud Messaging (FCM)

–  Formerly known as GCM

•  Send Messages –  Notification (for user) –  Data (for app)

https://firebase.google.com/docs/cloud-messaging/

Page 31: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Notifications •  Send notifications to app users •  Fine-grained control •  Integrated with Analytics

Source: Google

Page 32: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Adds / AddMob

Page 33: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Page 34: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Pricing

https://firebase.google.com/pricing/

Page 35: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Firebase as a Backend

https://firebase.google.com/

Page 36: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Just Firebase

https://cloud.google.com/solutions/mobile/mobile-app-backend-services

Page 37: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Using App Engine

https://cloud.google.com/solutions/mobile/mobile-app-backend-services

Page 38: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Custom Server

(Formerly known as Managed VMs)

https://cloud.google.com/solutions/mobile/mobile-app-backend-services

Page 39: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Existing Infrastructure

Synch through FB Add feature with FB

Page 40: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Hands-on Hacking/Demo •  Console

–  Firebase overview –  Database structure

•  ESP8266/Arduino –  FirebaseArduino library

•  Web –  Hosting –  Firebase CLI: setup and deploy –  FirebaseJS

•  Android –  Android Studio Firebase tricks –  Firebase SDK and patterns –  Firebase UI

Page 41: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Too Warm? Feeling Blue?

Page 42: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

CrimsonBreeze TM

Page 43: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Page 44: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Page 45: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Page 46: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

First: Setup Firebase

Page 47: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Hack#1: IoT board

Page 48: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Grove Sensors

Page 49: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Firebase on ESP8266/Arduino

•  FirebaseArduino library •  ESP8266 Arduino core •  “The Arduino library is under

heavy development, experimental, unversioned and its API is not stable”

https://github.com/googlesamples/firebase-arduino

https://github.com/esp8266/Arduino

Page 50: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Setup() !

Based on: https://github.com/googlesamples/firebase-arduino/tree/master/examples/FirebaseRoom_ESP8266

Page 51: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Loop() !

Based on: https://github.com/googlesamples/firebase-arduino/tree/master/examples/FirebaseRoom_ESP8266

Page 52: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Hack#2 Web

Page 53: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Web Interface

•  Plain old HTML, CSS and JavaScript •  FirebaseJS 3.4.1 •  Hosted on Firebase

Page 54: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Web Interface

Authenticate Monitor and control

Page 55: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Init

Page 56: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Deploy

Page 57: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

UI

Page 58: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Config & Auth

Page 59: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Database Synch

Page 60: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Hack#3 Android

Page 61: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Android Interface Authenticate Monitor and control

Page 62: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Getting Started

•  Create project (Firebase console) •  Add Android and configure •  Download and add google-services.json

to your Android project

Page 63: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Page 64: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Firebase SDK

<project>/<module>/build.gradle

<project>/build.gradle

Page 65: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Libraries

https://firebase.google.com/docs/android/setup

Page 66: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

FirebaseUI

•  FirebaseListAdapter •  FirebaseRecyclerViewadapter •  “FirebaseUI plans to add several more

features, including standard auth controls, pagination/infinite scroll, and navigation”

https://github.com/firebase/FirebaseUI-Android

Page 67: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Android Studio

Page 68: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Firebase Assistant

Page 69: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Firebase Assistant

•  Step by step guide •  Links to Firebase console – Auto-configure / fill

•  Configures Gradle and imports

Page 70: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Where to go from here?

•  https://firebase.google.com/ •  Firebase developer channel on Youtube – Google I/O 2016 videos – DevBytes

•  Firebase code labs – We are doing one right now!

•  Join ORBIT Lab / attend GDG Garage

Page 71: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

Firebase at Google I/O’16

•  Introducing Firebase https://www.youtube.com/watch?v=ySmWlU9j3j4

•  Firebase Overview https://www.youtube.com/watch?v=tb2GZ3Bh4p8

•  Firebase SDK for Android https://www.youtube.com/watch?v=AJqakuas_6g

Page 72: Introduction to Firebase with Android and Beyond...

Kasper Løvborg Jensen Leafcastle Labs | Aarhus University

THANK YOU! Questions?

@kasperlj

[email protected]


Recommended