Introduction to Firebase 2

Introduction to Firebase 2

32c638e7a3a466d182705fb4370cbb2e?s=128

Arnelle Balane

November 24, 2018
Tweet

Transcript

  1. Arnelle Balane @arnellebalane Web Developer, ChannelFix Introduction to

  2. bit.ly/firebase-bacolod

  3. You want to build an app

  4. None
  5. None
  6. None
  7. None
  8. None
  9. Build

  10. Improve

  11. Grow & Engage

  12. None
  13. None
  14. Creating a project Create and manage projects at https://console.firebase.google.com/

  15. Creating a project

  16. Creating a project

  17. Adding to your app https://www.gstatic.com/firebasejs/5.5.8/firebase.js via Google’s CDN

  18. Adding to your app via Google’s CDN firebase initializeApp

  19. Adding to your app via Firebase CLI

  20. Adding to your app via Firebase CLI "/__/firebase/5.5.8/firebase.js" "/__/firebase/init.js"

  21. None
  22. Email and Password Authentication Federated Authentication (Google, Facebook, Twitter, Github)

    Phone Number Authentication Email Link Authentication Anonymous Authentication
  23. Enabling email and password authentication

  24. Using the authentication service

  25. Create account with email and password createUserWithEmailAndPassword email password

  26. Logging in with email and password signInWithEmailAndPassword email password

  27. onAuthStateChanged Observing auth state

  28. Observing auth state

  29. Enabling federated authentication

  30. GoogleAuthProvider signInWithPopup provider Logging in with Google

  31. Logging in with Google

  32. FacebookAuthProvider TwitterAuthProvider GithubAuthProvider GoogleAuthProvider Logging in with other auth providers

  33. Logging in with passwordless auth sendSignInLinkToEmail email

  34. isSignInWithEmailLink location.href signInWithEmailLink email Logging in with passwordless auth

  35. Logging in with phone number

  36. signInWithPhoneNumber phoneNumber recaptchaVerifier Logging in with phone number

  37. Logging in with phone number confirmation confirm code

  38. signInAnonymously Logging in anonymously

  39. Account linking Sending confirmation emails Sending password reset emails Custom

    authentication system Custom claims More features FirebaseUI
  40. None
  41. None
  42. NoSQL Cloud Database Stores data as JSON Syncs data across

    connected clients in realtime Offline capabilities
  43. Stores data as JSON

  44. Accessing parts of the database Reference

  45. Accessing parts of the database "posts" "first-post" { "title": "First

    Post", "created_at": "2018-11-01" } Reference posts/first-post
  46. Accessing parts of the database "posts" "first-post" "title" "First Post"

    Reference posts/first-post/title
  47. Using the realtime database service

  48. Creating a reference database.ref 'posts/third-post'

  49. Writing data to the database reference set

  50. Structuring our data

  51. Structuring our data

  52. Structuring our data "comments": { "1": { "content": "nice!" },

    "2": { "content": "cooool!" } ... }
  53. Structuring our data

  54. Reading data from the database reference on 'value'

  55. Reading data from the database 'value' 'child_added' 'child_removed' 'child_changed' 'child_moved'

  56. value Reading data from the database

  57. Deleting data from the database reference remove

  58. Detecting when you go offline '.info/connected'

  59. Detecting when you go offline

  60. Letting others know you are offline connectionRef onDisconnect

  61. Security rules

  62. Security rules true "auth.uid === $uid"

  63. Security rules database.rules.json

  64. None
  65. NoSQL Cloud Database Organizes data in documents and collections Syncs

    data across connected clients in realtime More expressive querying capabilities Offline support for mobile and web
  66. None
  67. Using the firestore service

  68. Creating collection and document references collection 'posts' doc 'first-post' doc

    'posts/first-post'
  69. Writing data to the database documentRef set

  70. Writing data to the database

  71. Reading a document from the database doc 'posts/first-post' documentRef get

  72. Reading a document from the database data

  73. collection 'posts' collectionRef get Reading a collection from the database

  74. snapshot forEach data Reading a collection from the database

  75. Filtering the results where 'is_published' '==' true

  76. Structuring our data

  77. Structuring our data "posts" "first-post" ⇒ collection ⇒ document

  78. Structuring our data "posts" "first-post" "comments" "1" "2" ⇒ collection

    ⇒ document ⇒ collection ⇒ document ⇒ document
  79. collection 'posts' collectionRef onSnapshot Realtime updates

  80. Realtime updates doc 'posts/first-post' documentRef onSnapshot

  81. Security rules

  82. match /posts/{post} if request.auth != null Security rules

  83. Security rules match /comments/{comment}

  84. Security rules read write get list create update delete

  85. Security rules firestore.rules

  86. Data Storage Offline Support JSON Collections, Documents Android, iOS Android,

    iOS, Web Querying Deep queries Shallow queries lesser need for denormalization or data flattening returns the entire subtree thanks to subcollections https://firebase.google.com/docs/firestore/rtdb-vs-firestore
  87. None
  88. Highly scalable object storage

  89. Using the storage service

  90. Uploading a file storage ref 'avatars/arnellebalane.jpg'

  91. Uploading a file reference put file

  92. Monitoring upload progress 'state_changed'

  93. Monitoring upload progress upload upload bytesTransferred upload totalBytes

  94. reference getDownloadURL Obtaining the file’s URL

  95. reference delete Deleting a file

  96. Security rules

  97. Security rules match /avatars/{image} if request.auth != null && request.resource.contentType.matches('image/.*')

  98. Security rules storage.rules

  99. More features Pause/resume file uploads Custom file metadata

  100. None
  101. Fast and secure hosting for Web applications Quickly and easily

    deploy apps and content into a global CDN Secured with SSL
  102. firebase deploy https://firebase-example.firebaseapp.com/ Deploying our site

  103. Custom domains One-click rollbacks

  104. None
  105. Automatically run backend code in response to events and requests

    Our code is stored and runs in a managed environment on Google’s cloud
  106. Cloud Firestore Triggers Realtime Database Triggers Cloud Functions triggers Firebase

    Authentication Triggers Cloud Storage Triggers Remote Config Triggers Google Analytics for Firebase Triggers Crashlytics Triggers Cloud Pub/Sub Triggers HTTP Triggers
  107. Enabling Cloud Functions for Firebase

  108. functions Enabling Cloud Functions for Firebase

  109. Cloud Function for HTTP Triggers

  110. Cloud Function for HTTP Triggers

  111. helloWorld Cloud Function for HTTP Triggers

  112. https onRequest Cloud Function for HTTP Triggers

  113. request response Cloud Function for HTTP Triggers

  114. Cloud Function for HTTP Triggers

  115. Deploying Cloud Functions

  116. Deploying Cloud Functions

  117. Deploying Cloud Functions

  118. Cloud Function for HTTP Triggers

  119. Cloud Function for Firebase Authentication Triggers

  120. sendWelcomeEmail auth user() onCreate user Cloud Function for Firebase Authentication

    Triggers
  121. Cloud Function for Cloud Storage Triggers

  122. generateImageThumbnails storage object() onFinalize object Cloud Function for Cloud Storage

    Triggers
  123. More Cloud Functions guides at https://firebase.google.com/docs/functions/

  124. None
  125. Brings Google’s ML expertise in a powerful yet easy-to-use package

    for Android and iOS Provides ready-to-use APIs for common use cases Use custom TensorFlow Lite models Run on-device or in the cloud
  126. Face Detection Barcode Scanning Image Labelling Ready-to-use APIs Text Recognition

    Landmark Recognition
  127. Know more at https://firebase.google.com/docs/ml-kit/

  128. Firebase Admin SDK

  129. Interact with Firebase from our server Firebase Admin SDK

  130. Installation Firebase Admin SDK

  131. Installation Firebase Admin SDK Also available in:

  132. Obtain a service account key Firebase Admin SDK

  133. Initializing the SDK Firebase Admin SDK

  134. Initializing the SDK Firebase Admin SDK

  135. Initializing the SDK serviceAccount admin initializeApp serviceAccount Firebase Admin SDK

  136. admin database Initializing the SDK Firebase Admin SDK

  137. Firebase CLI firebase-tools

  138. Installation Firebase CLI

  139. Installation and setup Firebase CLI

  140. Initializing a Firebase project Firebase CLI

  141. Initializing a Firebase project Firebase CLI

  142. Initializing a Firebase project Firebase CLI

  143. Initializing a Firebase project Firebase CLI database.rules.json

  144. Initializing a Firebase project Firebase CLI firestore.indexes.json firestore.rules

  145. Initializing a Firebase project Firebase CLI functions index.js package.json

  146. Initializing a Firebase project Firebase CLI public 404.html index.html

  147. Initializing a Firebase project Firebase CLI storage.rules

  148. Commands Firebase CLI

  149. Commands Firebase CLI

  150. Commands Firebase CLI

  151. https://firebase.google.com/

  152. Arnelle Balane @arnellebalane Web Developer, ChannelFix Introduction to