Busy programmer’s guide to Firebase with Android.
Minimum price
Suggested price

Busy programmer’s guide to Firebase with Android.

About the Book

Andrew Lee and James Tamplin founded firebase in 2011. Its initial product was a real-time database, which provides an API that allows mobile and web developers to store and sync data across multiple clients. The company has expanded its product line to become a full suite platform for the web and mobile development. Google acquired the company in October 2014, and a significant number of new features were added.

This book teaches you how to integrate Firebase Android SDK Version 11.2.0 in your Android application. Firebase helps developers to build high-quality apps, grow user base of the apps and earn more money. There are several unique services provided by Firebase. Some of them are Firebase Analytics, development tools and tools for user base growth. Most of these tools are free, and there are tools in paid plans as well.

Developers can use Firebase for heavy tasks in the application. Some of the development tools provided by Firebase for Android application development are real-time Database, Crash Reporting, Authentication, Cloud Functions, Cloud Storage, Test Lab for Android, and Performance monitoring tools. 

Some of the tools provided by Firebase are for user growth and user engagement. They are Google Analytics for Firebase, Cloud Messaging, Dynamic Links, Remote Config, Invites, App Indexing, AdMob, and Adwords. You will learn how to use each tool in your Android application.

Table of Contents


Prerequisites. 16

Java Programming Language. 17

What is Java?. 18

Object Oriented Programming Language. 20

Android Development Environment. 22

How to install Android Studio 2.3.3?. 22

Installation. 23

Install the Google Play Services SDK.. 28

Firebase Console. 29

Pricing. 31

Summary. 32

Add Firebase to Your Android Project. 33

Introduction. 33

Creating a new Android Project. 33

Creating a new project in Firebase Console. 37

Modify your build.gradle files. 43

Use the Firebase Assistant. 47

Get the Debug Certificate. 49

Available Libraries. 53

Summary. 53

Firebase Analytics. 54

Introduction. 54

Difference between Firebase Analytics and Google Analytics. 55

Firebase Console Demo Project. 55

Active Users. 60

Average Revenue. 60

Ad Performance. 61

In-app Purchases. 61

first_open Attribution. 62

Retention Cohorts. 62

User Engagement. 63

App Version. 63

Devices. 64

Location. 64

Demographics. 65

Interest. 66

Automatically Collected Events. 69

User Properties. 72

Integrating Firebase Analytics. 75

Explanation. 78

Common Error. 80

Audiences. 81

Summary. 83

Firebase Notifications. 84

Introduction. 84

Implementation Path. 85

Difference between Notifications and Cloud Messaging. 85

Integrate Firebase Notifications. 86

Send a message from the Notifications Console. 91

Console fields and the message payload.. 93

Receive and handle Notifications. 94

Custom Notification Icon and Colour. 95

Send a Notification to a Device. 96

Subscribe to a topic. 97

Send Topic Messages from the Notifications Console. 99

Send Messages from the Notifications Console to specific device. 100

Summary. 102

Firebase Cloud Messaging with PHP. 103

Introduction. 103

FCM Messages. 104

Notification Messages. 105

Data Messages. 106

Messages with both Notification and Data Payloads. 106

Non-collapsible and Collapsible Messages. 107

Priority of a Message and Message Targeting. 108

Integrate Firebase Cloud Messaging with PHP. 109

Obtain Firebase Server API Key. 109

Creating a PHP Web Application to Send Messages. 111

Summary. 117

Firebase Realtime Database. 118

Introduction. 118

Structure of the Firebase Database. 119

Avoid deep nesting data. 120

Denormalization. 120

Create Data That Scales. 120

Set up Firebase Real Time Database for Android.. 120

Configure Firebase Database Rules. 121

Rule Types. 121

Firebase Database Predefined Variables. 121

Advanced Firebase Rules. 123

Validate Rules. 124

Write to your Database. 125

Read from your Database. 126

Deleting Data. 126

Configure ProGuard.. 126

Offline Support (Disk Persistence). 127

Database in Firebase Console. 127

Example Application. 130

Summary. 140

Firebase Authentication. 141

Introduction. 141

Key Capabilities. 142

Authentication in the Firebase Console. 142

Authentication Implementation Steps. 146

Firebase Authentication Using Email 146

User Registration Using Email 146

Sign In Using Email 152

Recover Password Using Email 155

User Sign Out. 160

Change User Email 161

Check User Session. 161

Delete User. 161

Summary. 162

Firebase Storage. 163

Introduction. 163

Creating Storage Structure. 163

Setup.. 165

Add the Firebase Storage Dependencies to the Project. 165

Set up Firebase Storage. 165

Create a Storage Reference on Android.. 166

Navigate with References. 166

References Properties. 166

Limitations on References. 167

Upload Files. 167

Manage Uploads. 167

Handle Errors. 167

Firebase Storage Security Rules. 169

File Upload Example. 170

Storage implementation overview.. 171

Add Application Permissions. 179

Security Rules in Firebase Console. 179

Summary. 181

Firebase Remote Config. 182

Introduction. 182

Key Capabilities. 182

How it works?. 183

Implementation path. 183

Don’t use Firebase Remote Config in following scenarios. 183

Caching. 183

Firebase Remote Config Example. 184

Setting up the parameter values on the Firebase console. 186

Add conditions. 187

Add Remote Config to the Android project. 189

Application logic in MainActivity class. 190

XML default file. 190

Fetch remote values. 191

Summary. 192

Firebase Crash Reporting. 194

Introduction. 194

Key capabilities. 194

Setup Firebase Crash Reporting. 195

Report crashes. 197

User Privacy. 198

Summary. 198

AdMob. 199

Introduction. 199

How does it work?. 199

Get started.. 199

Integrate the Mobile Ads SDK.. 200

Creating an ad unit. 200

Configuration of the Android app.. 202

Place an AdView.. 202

Initialize the Google Mobile Ads SDK.. 203

Load the ad.. 203

Banner ads. 205

Smart ads. 205

Interstitial Ads. 206

Implementing interstitial ads. 206

In-App Purchase Ads. 208

Adding permissions and activity required for In-App Purchase Ads. 208

Implementation. 209

PlayStorePurchaseListener implementation. 209

Native Ads. 210

Summary. 210

Firebase Invites. 211

Introduction. 211

How Firebase Invites Work?. 211

Implementation Path. 212

Adding Firebase Invites to the Android App.. 212

Send Invitations. 212

Customize The Invitation. 213

Receive Invitations. 215

Summary. 217

Firebase Dynamic Links. 218

Introduction. 218

Create Dynamic Links. 219

Create Firebase Dynamic Links Using Firebase Console. 219

Handling Dynamic Links in Android Application. 224

Add the Library Dependency. 224

Add an Intent Filter for Deep Links. 224

View Dynamic Links Analytics Data. 225

Summary. 227

Firebase App Indexing. 228

Introduction. 228

How does Firebase App Indexing work?. 228

Add Firebase and the App Indexing library. 228

Preperation of links. 229

Enable Content Indexing. 229

Enable Personal Content Indexing. 232

Update the index. 234

Delete the index when users log out. 234

Summary. 234

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

80% Royalties. Earn $16 on a $20 book.

We pay 80% royalties. That's not a typo: you earn $16 on a $20 sale. If we sell 5000 non-refunded copies of your book or course for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earnedover $13 millionwriting, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub