O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Mastering Firebase for Android Development

Book Description

Develop a fully functional dynamic Android application using the latest features of Firebase

About This Book
  • Explore all the latest tools in Firebase—Firebase Firestore, ML-Kit, and Firebase Predictions
  • Master Firebase cloud messaging, remote configuration, and work with a real-time database
  • Make your app a global success with the help of Google Analytics and AdMob
Who This Book Is For

Mastering Firebase for Android Development is for individualslooking to extend their skills with Firebase and build faster, scalable, and real-time mobile applications. Basic understanding of Android programming is necessary. In all, this in-depth guide is an accessible pathway to mastering Firebase.

What You Will Learn
  • Learn about Firebase push notifications and write backend functionalities
  • Identify the root cause of an application crash and diagnose and fix bugs
  • Store different Multipurpose Internet MailExtension(MIME) type files
  • Explore web hosting and connect the Firebase functions to the host website
  • Send push notifications and understand the deep integration of analytics tools and cohorts
  • Market and monetize your application using Firebase Adwords and Admob
  • Build a secure authentication framework while enhancing the sign-in and on-boarding experience for end users
In Detail

Firebase offers a wide spectrum of tools and services to help you develop high-quality apps in a short period of time. It also allows you to build web and mobile apps quickly without managing the infrastructure.Mastering Firebase for Android Development takes you through the complete toolchain of Firebase,including the latest tools announced in Google IO 2018 such as Firebase ML-Kit, FireStore, and Firebase Predictions.

The book begins by teaching you to configure your development environment with Firebase and set up a different structure for a Firebase real-time database. As you make your way through the chapters, you'll establish the authentication feature in Android and explore email and phone authentication for managing the on-boarding of users. You'll be taken through topics on Firebase crash reporting, Firebase functions, Firebase Cloud, Firebase Hosting, and Cloud Messaging for push notifications and explore other key areas in depth. In the concluding chapters, you will learn to use Firebase Test Lab to test your application before using Firebase Performance Monitoring to trace performance setbacks.

By the end of the book, you will be well equipped with the Firebase ecosystem, which will help you find solutions to your common application development challenges.

Style and approach

A step by step guide taking you through the different features of Firebase

Downloading the example code for this book You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Table of Contents

  1. Title Page
  2. Copyright and Credits
    1. Mastering Firebase for Android Development
  3. Dedication
  4. Packt Upsell
    1. Why subscribe?
    2. PacktPub.com
  5. Contributors
    1. About the author
    2. About the reviewers
    3. Packt is searching for authors like you
  6. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Conventions used
    4. Get in touch
      1. Reviews
  7. Keep It Real – Firebase Realtime Database
    1. Firebase Realtime Database
    2. Setting up a development environment 
      1. Prerequisites 
      2. Configuring Firebase in Android projects
    3. Reading and writing to Realtime Database
      1. Database reference 
      2. Writing into Realtime Database
      3. Reading from Realtime Database
      4. Structuring the data with objects
      5. Reading the objects from Firebase
      6. Reading value changes 
        1. Parsing the DataSnapshot object
      7. Updating data
      8. Writing HashMaps to Realtime Database
      9. Realtime Database and lists
      10. Deleting data
        1. Offline capabilities
    4. Realtime Database rules
      1. Default security rules
      2. Database rules and types
        1. Customizing database rules
        2. Data security
      3. Custom variables 
      4. Default variables
        1. RuleDataSnapshot and its methods
    5. Creating an Android application using Realtime Database
      1. User interface design
      2. Logic
    6. Summary
  8. Safe and Sound – Firebase Authentication
    1. Firebase Authentication
    2. Setting up Firebase Authentication
      1. FirebaseUI Auth authentication
      2. Firebase SDK Authentication
    3. FirebaseUI Email Authentication
      1. Configuring for Email Authentication
      2. Enabling Email/Password Authentication in Console
      3. Initializing Firebase Authentication
      4. Finalizing the project
    4. Firebase SDK Email Authentication
      1. Sign up new users
      2. Sign in existing users
      3. Managing users
        1. Provider-specific user profile details
        2. Profile updating
        3. Sending a verification Email 
        4. Forgot password
        5. Deleting a user
      4. Managing users through console
        1. Smart Lock 
    5. FirebaseUI social networking site authentication
      1. Google Sign-in
        1. SHA-1 fingerprint
        2. Code for Google provider
      2. Facebook Login
        1. Facebook App ID and App secret
        2. Project configuration
      3. Twitter Sign-in
        1. Twitter Api key
        2. Project Configuration
      4. Phone number sign-in
        1. Project configuration
    6. Firebase SDK social networking site authentication
      1. Google sign-in 
      2. Facebook login
      3. Twitter sign-in 
      4. Phone number sign-in 
      5. Anonymous Authentication
      6. Link multiple Auth providers
      7. Firebase Authentication failures
        1. Firebase Authentication exceptions
    7. Summary 
  9. Safe and Sound – Firebase Crashlytics
    1. Firebase Crash Reporting and Crashlytics
    2. Firebase Crash Reporting setup 
      1. Creating crash reports
      2. Creating custom logs
      3. Deobfuscating ProGuard labels
      4. Crash Report support for multiple APK
      5. Disabling Crash Reporting
    3. Firebase Crashlytics 
      1. Firebase Crashlytics setup and upgrading from Crash Reporting
      2. Migrating from Firebase Crash Reporting to Crashlytics
      3. Validating Crashlytics implementation
      4. Enabling Crashlytics debug mode
      5. Customizing Crashlytics reports
      6. Crashlytics and functions
    4. Summary
  10. Genie in the Cloud – Firebase Cloud Functions
    1. Firebase Cloud Functions
      1. Set up the development environment
        1. Project structure
          1. Required modules
          2. Deploying Cloud functions project
          3. Custom logs and reviewing functions
    2. Trigger functions 
      1. Cloud Firestore Triggers
        1. Specific documents
        2. Creating a document
        3. Updating documents
        4. Deleting a document
        5. Changes in a document
      2. Realtime Database Triggers 
      3. Firebase Authentication Triggers
      4. Analytics and Crashlytics Triggers
      5. Cloud Storage Triggers
      6. HTTP Triggers
      7. Cloud Pub/Sub Triggers
    3. Writing Firebase functions
      1. Cloud Functions to fire a push notification
    4. Summary
  11. Arsenal for Your Files – Firebase Cloud Storage
    1. Firebase a Cloud Storage
    2. Creating storage reference
      1. Storage reference properties
      2. Limitations of reference
    3. Uploading and downloading files
      1. Uploading files 
        1. Uploading existing files
        2. Uploading files as a stream
        3. Uploading from data in memory
        4. Managing file upload
        5. Monitoring file upload
        6. Beyond monitoring and managing 
      2. Downloading files 
        1. Creating a reference
        2. Downloading into memory
        3. Downloading into a local file
        4. Downloading data through a URL 
        5. Downloading images using FirebaseUI
        6. Beyond downloading files
    4. File metadata
      1. Retrieving File Metadata
      2. Update the metadata of the file
      3. Deleting files
      4. Handling common errors
      5. Security and rules
        1. The general syntax for storage security rules
        2. Securing user files
        3. Request and Resource Evaluation 
    5. Storage and functions 
      1. Firebase Storage in practice 
    6. Summary
  12. Not Just a Keeper, Firebase Hosting
    1. Firebase Hosting
    2. Deploying a website
    3. Connecting to custom domain
    4. Connecting Firebase cloud functions
    5. Customizing hosting behavior
      1. Custom 404/Not Found page
      2. Redirects
      3. Rewrites 
      4. Headers 
      5. Hosting priorities
    6. Reserved URLs
    7. Summary
  13. Inspection and Evaluation – Firebase Test Lab
    1. Firebase Test Lab
      1. Test Lab for Android
        1. Choosing the testing method
        2. Robo testing 
        3. Choosing device type and reviewing test results
      2. Test Lab with Firebase Console
      3. Test Lab with gcloud CLI 
        1. Google Cloud SDK environment
        2. Choosing test configurations
        3. Scripting gcloud commands with Test Lab
      4. Test Lab with CI systems
        1. Creating a Jenkins project 
      5. Test Lab with Android Studio
    2. Firebase Test Lab results
      1. Available devices in Test Lab
    3. Firebase Test Lab Game Loop testing 
      1. Test Loop Manager
      2. Game loop in Test Lab
    4. Prelaunch reports 
    5. Summary
  14. A Smart Watchdog – Firebase Performance Monitoring
    1. Firebase Performance Monitoring
      1. Performance Monitoring for Android
        1. Automatic traces
      2. Custom trace and counters
        1. Performance Monitoring for Android performance
        2. Monitoring for specific network requests
      3. Monitoring custom attributes
        1. Enabling Logcat output
        2. Firebase Console for Performance Monitoring
    2. Summary
  15. Application Usage Measuring and Notification, Firebase Analytics, and Cloud Messaging
    1. Firebase Analytics
      1. Firebase Analytics for Android
        1. Setting user properties
        2. Analytics in a WebView
        3. Debugging events
        4. Firebase Analytics and functions
    2. Cloud Messaging
      1. Firebase Cloud Messaging in Android
        1. Accessing the device registration token 
      2. Cloud Messaging explained
        1. Sending the first notification
    3. Summary
  16. Changing Your App – Firebase Remote Config and Dynamic Links
    1. Firebase Remote Config
      1. Setting up Remote Config on Android
        1. Remote Config's singleton object
        2. In-app parameters
        3. Accessing the Remote Config parameters
        4. Server-side parameters
        5. Fetching the parameters
        6. Activating parameters
        7. Conditions, rules, and values
        8. Remote Config and Google Analytics
      2. A/B Testing with Remote Config
    2. Firebase Dynamic Links
      1. Dynamic Links use cases
        1. Converting mobile web users to native app users
        2. Sharing content between users
        3. Rewarding referrals using Firebase 
        4. The anatomy of Dynamic Links
        5. Creating Dynamic Links
        6. Receiving Dynamic Links
    3. Summary
  17. Bringing Everyone on the Same Page, Firebase Invites, and Firebase App Indexing
    1. Firebase Invites
      1. Sending and receiving invites from Android applications 
    2. Firebase App Indexing
      1. Enabling public content indexing
      2. Enabling personal content indexing
      3. Logging user actions
        1. Testing your implementation
        2. Search performance and latest APIs
    3. Summary
  18. Making a Monetary Impact and Firebase AdMob and AdWords
    1. Firebase AdWords
      1. Creating an AdWords account
      2. Linking AdWords to Firebase
      3. Tracking app conversions with Firebase
    2. AdMob
      1. Android Studio and initializing the SDK
    3. Summary 
  19. Flexible NoSQL and Cloud Firestore
    1. Cloud Firestore
      1. Adding and managing data
      2. Choosing a data structure for your Firestore project
      3. Querying data
        1. Securing data
      4. Offline data support
    2. Summary
  20. Analytics Data, Clairvoyant, Firebase Predictions
    1. Firebase Predictions 
      1. Setting up Firebase Predictions
      2. Optimizing monetization
      3. Optimizing promotions
      4. Preventing churn
      5. Predefined predictions
      6. Predictions and risk tolerance
    2. Summary
  21. Training Your Code and ML Kit
    1. Firebase ML Kit
    2. Vision
      1. Recognizing text
        1. Setting up ML Kit for recognizing text
        2. On-device text recognition
        3. Cloud-Based text recognition
      2. Face detection
        1. Setting up ML Kit for face detection
      3. Barcode scanning 
        1. Setting up ML Kit for barcode scanning 
    3. Custom models 
      1. ML Kit and text recognition 
    4. Summary
  22. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think