Firebase Complete Guide for Xamarin

Firebase

Firebase is part of a growing trend known as “Back end as a service”. Traditionally configuration of a server would require you to fetch data via some API you have written in order to retrieve data from your server.  When using SQL, you would have to write code that stores objects and properties that can be accessed in your code.

A cloud-hosted NoSQL database. Data is stored as JSON, synced across connected devices in milliseconds, and available when your app goes offline. Intuitive and easy-to-use API. Remains responsive regardless of network latency or Internet connectivity so apps works offline.

What is amazing about Firebase, is that essentially with one line of code, you are ready to begin writing to your database instantly. This gets stored as JSON (JavaScript Object Notation) and can be read and used in your application nearly as easily.

Firebase expedites the storing and retrieving of data via a third party service and comes with its own API so you don’t have to write one.

firebase

Advantages

  • It is a versatile backend with a lot of good uses.
  • Free and unlimited app analytics
  • User insights from acquisition to app usage
  • It is cut down development time and avoids messing with servers and data storage.
  • Data is reflected and backed up to multiple secure locations, so there are minimal chances of data loss.
  • It is Scalable. If you want your application to scale well, you can trust that Firebase will handle all your data without missing a single step.
  • Data is safe because Firebase requires 2048-bit SSL encryption for all data transfers.
  • It provides cloud service, so there isn’t any setup involved.
  • Data is stored as native JSON, so what you store is what you see.

 Firebase Features Comparison

Firebase Feature Paid
Analytics No
App Indexing, Authentication, Cloud Messaging, Crash Reporting, Dynamic Links, Invites, Notifications & Remote Config No
Real Time Database Yes
Hosting Yes
Google Cloud Platform Yes
Test Lab No (limit to 15 tests per day)


Note
: Firebase offers 3 plans that includes all of the features. For the more specifications and pricing, refer this.

Firebase Analytics

Firebase Analytics provides free, unlimited reporting on up-to 500 distinct events and it is one of the powerful feature of firebase. The SDK automatically captures certain key events and user properties, and you can define your own custom events to measure the things that uniquely matter to your business.

Technical Document for the firebase analytics.

The SDK automatically captures a number of events and user properties and also allows you to define your own custom events to measure the things that uniquely matter to your business. Once the data is captured, it’s available in a dashboard through the Firebase console. This dashboard provides detailed insights about your data — from summary data such as active users and demographics, to more detailed data such as identifying your most purchased items.

How to start with Firebase Analytics

iOS

iOS developers can download Firebase analytics Xamarin component from here or directly add component into the project. After adding the component, Please refer the firebase analytics doc to start logging the events.

Android

Android developers can start by installing this nuget package. I cannot find any ready made Xamarin component for the firebase analytics but we can use nuget package as the alternative of it.

Viewing event data in Firebase Console.

Wait a little while

Firebase analytics will only send data either the data sitting around more than an hour old or if the app goes into the background in order to respectful of our user’s battery.

Linking to BigQuery

It will link the app with the big query which will lets us to analyse and write the BigQuery against analytics data as soon as it reported.   

Firebase Cloud Messaging

Firebase Cloud Messaging (FCM) is the new version of GCM. It inherits the reliable and scalable GCM infrastructure, plus new features! See the FAQ to learn more. If you are integrating messaging in a new app, start with FCM. GCM users are strongly recommended to upgrade to FCM, in order to benefit from new FCM features today and in the future.

Google is investing in Firebase, making it our unified mobile platform.

Using Firebase Cloud Messaging, you can notify a client app that new email or other data is available to sync. You can send notification messages to drive user re-engagement and retention. For use cases such as instant messaging, a message can transfer a payload of up to 4KB to a client app.

Key capabilities

  • Send notification messages or data messages: Send notification messages that are displayed to your user. Or send data messages and determine completely what happens in your application code. See Message types.
  • Versatile message targeting: Distribute messages to your client app in any of three ways — to single devices, to groups of devices, or to devices subscribed to topics.
  • Send messages from client apps: Send acknowledgments, chats, and other messages from devices back to your server over FCM’s reliable and battery-efficient connection channel.

The New FCM SDK:

  1. Simplifies client development. You no longer have to write your own registration or subscription retry logic.
  2. Enables a new server-less notifications solution with a web console, Firebase Notifications. With Firebase Notifications, anyone can send notifications to target specific audiences based on Firebase Analytics insights. They can then evaluate notification effectiveness by assessing the built-in Notifications Funnel Analysis in the console.
  3. FCM Android and iOS SDKs make messaging and notifications development easier. They offer an out-of-the-box solution so that anyone can send notifications from Firebase Notifications immediately.
  4. Google will continue to support the current version of GCM Android and iOS SDKs because they know a lot of developers are using GCM SDKs today to handle notifications, and client app upgrade takes time.
  5. But all new client-side features will be added to FCM SDKs only moving forward. You are strongly encouraged to upgrade to FCM SDKs.

How to start with Firebase Cloud Messaging

iOS

iOS developers can download Firebase Cloud messaging Xamarin component from here or directly add component into the project. After adding the component, Please refer the firebase cloud messaging doc to start using it.

Android

Android developers can refer the complete Xamarin guide for Firebase Cloud Messaging from here. For the complete documentation refer this.

Firebase Remote Config

Firebase Remote Config is a cloud service that lets you change the behavior and appearance of your app without requiring users to download an app update. When using Remote Config, you create in-app default values that control the behavior and appearance of your app. Then, you can later use the Firebase console to override in-app default values for all app users or for segments of your userbase. Your app controls when updates are applied, and it can frequently check for updates and apply them with a negligible impact on performance.

Remote Config gives us the power to:

  • Quickly and easily update our applications without the need to publish a new build to the app / play store. For example, we could easily switch out a rebuild of a component in our application for a select set of users based on the conditions that we specify.
  • We can effortlessly set how a segment behaves or looks in our application based on the user / device that is using it. For example, we may wish to switch out a component for users in Europe than one that may be shown for users in the US.
  • Following on from the above, we can use Remote Config to A/B test parts of our applications with a defined set of users before you decide to release something to your entire user base.

How to start with Firebase Remote Config

iOS

iOS developers can download Firebase Remote Config Xamarin component from here or directly add component into the project. After adding the component, Please refer the firebase remote config doc to start using it.

Android

Android developers can refer the complete Xamarin nuget package for Firebase Remote config from here.

Firebase Dynamic Links

Firebase Dynamic Links are links that work the way you want, on multiple platforms, and whether or not your app is already installed.

With Dynamic Links, your users get the best available experience for the platform they open your link on. If a user opens a Dynamic Link on iOS or Android, they can be taken directly to the linked content in your native app. If a user opens the same Dynamic Link in a desktop browser, they can be taken to the equivalent content on your website.

In addition, Dynamic Links work across app installs: if a user opens a Dynamic Link on iOS or Android and doesn’t have your app installed, the user can be prompted to install it; then, after installation, your app starts and can access the link.

You create a Dynamic Link either by using the Firebase console, using a REST API, or by forming a URL by adding Dynamic Link parameters to a domain specific to your app. These parameters specify the links you want to open, depending on the user’s platform and whether your app is installed.

When a user opens one of your Dynamic Links, if your app isn’t yet installed, the user is sent to the Play Store or App Store to install your app (unless you specify otherwise), and your app opens. You can then retrieve the link that was passed to your app and handle the link as appropriate for your app.

Key capabilities

  • Dynamic Links are durable and survive app installs: Delight users by personalizing the first-open experience. Avoid losing conversions when potential users don’t already have your app installed.
  • Dynamically control the user experience: Dynamic Links work seamlessly across iOS, Android, and desktop and mobile web. Dynamic Links can be configured to provide the best possible user experience, whether that’s a personalized app launch, a fast interstitial, or opening your mobile website.
  • Know which content and campaigns are working: Use Dynamic Links in marketing campaigns and for content sharing to know exactly which campaigns and content drive growth.

Firebase Dynamic Links vs DeepLinks

Firebase dynamic links are the deep links that works the way you want to them.So you can create one single link that behaves one way on iOS and another on Android and even third on a desktop and it will take you to the place appropriate to that platform.

What makes dynamic links different to to the deep links ?

Dynamic links can survives the app store installation process so if your users installs the app by clicking on the dynamic links all the information is still be available when users opens up the app first time.  

How to start with Firebase Dynamic Links

iOS

iOS developers can download Firebase Dynamic Links Xamarin component from here or directly add component into the project. After adding the component, Please refer the firebase remote config doc to start using it.

Android

There is no nuget package available yet !!

Firebase Test Lab

Firebase Test Lab for Android provides cloud-based infrastructure for testing Android apps. With one operation, you can initiate testing of your app across a wide variety of devices and device configurations. Test results—including logs, videos, and screenshots—are made available in your project in the Firebase console. Even if you haven’t written any test code for your app, Test Lab can exercise your app automatically, looking for crashes.

Key Capabilities

  • Test on real devices :  Use Test Lab to exercise your app on devices installed and running in a Google data center. Test Lab helps you to find issues that only occur on specific device configurations (for example, a Nexus 5 running a specific Android API level and specific locale settings).

 

  • Run app tests, even if you haven’t written any : You can use Robo test to find issues with your app so you can test your app even if you haven’t written app tests. Robo test analyzes the structure of your app’s user interface and then explores it, automatically simulating user activities. If you have written instrumentation tests for your app, Test Lab can also run those tests.
  • Workflow integration : Test Lab is integrated with Android Studio, the Firebase console, and the gcloud command line. You can also use Test Lab with Continuous Integration (CI) systems.

Yeah !! We can use Test Labs with Jenkins Continuous Integration. Click here to know How !

How does it work?

Test Lab uses devices running in a Google data center to test your app. The devices used for testing are real production devices that are flashed with updated Android API levels or locale settings that you specify so that you can road-test your app against a real-world collection of real devices and device configurations.

How to start with Firebase Test Lab

iOS

Firebase Test Lab is not available for iOS, even it is not required for iOS as we have limited devices in iOS.

Android

For Android we don’t need to right any lines of code in the project to use the test lab we can directly upload the .apk file and run the different test cases from Firebase console.  

Firebase Realtime Database

The Firebase Realtime Database is hosted in the cloud. Your data is stored as JSON and synchronized in real time to all connected clients.

The Firebase Realtime Database lets you share your database across Android, IOS and Web apps.

Firebase data is also available offline, so your app always has access to your data. The data is automatically synced once the app comes back online.

When you build cross-platform apps with our iOS, Android, and JavaScript SDKs, all of your clients share one Realtime Database instance and automatically receive updates with the newest data.

  • Realtime – means that data is synchronised with all connected devices within milliseconds of changes being made to the data
  • Offline – The Firebase Realtime Database persists your data on your device so the data is always available, even offline. The data is synced with the cloud on reconnection
  • Accessible from client devices – the Firebase Realtime Database can be accessed from a mobile device (Android or IOS) or Web app
  • Security – you define your security rules which controls who has what access to your Firebase database. You can also integrate Firebase Authentication to control access to your data

How does it work?

The Firebase Realtime Database lets you build rich, collaborative applications by allowing secure access to the database directly from client-side code. Data is persisted locally, and even while offline, realtime events continue to fire, giving the end user a responsive experience. When the device regains connection, the Realtime Database synchronizes the local data changes with the remote updates that occurred while the client was offline, merging any conflicts automatically.

The Realtime Database provides a flexible, expression-based rules language, called Firebase Realtime Database Security Rules, to define how your data should be structured and when data can be read from or written to. When integrated with Firebase Authentication, developers can define who has access to what data, and how they can access it.

The Realtime Database is a NoSQL database and as such has different optimizations and functionality compared to a relational database. The Realtime Database API is designed to only allow operations that can be executed quickly. This enables you to build a great realtime experience that can serve millions of users without compromising on responsiveness. Because of this, it is important to think about how users need to access your data and then structure it accordingly.

How to start with Firebase Realtime Database

iOS

iOS developers can download Firebase Realtime Database component from here or directly add component into the project. After adding the component, Please refer the firebase realtime database doc to start using it.

Android

Android developers can refer github link  for Firebase Realtime Database from here. For nuget package download  this.

Firebase Storage

It adds Google security to file uploads and downloads for your Firebase apps, regardless of network quality. You can use it to store images, audio, video, or other user-generated content. Firebase Storage is backed by Google Cloud Storage, a powerful, simple, and cost-effective object storage service.

Key capabilities

  • Robust operations: It performs uploads and downloads regardless of network quality. Uploads and downloads are robust, meaning they restart where they stopped, saving your users time and bandwidth.
  • Strong security: It integrates with Firebase Authentication to provide simple and intuitive authentication for developers. You can use our declarative security model to allow access based on filename, size, content type, and other metadata.
  • High scalability: It is backed by Google Cloud Storage for petabyte scale when your app goes viral. Effortlessly grow from prototype to production using the same infrastructure that powers Snapchat.

How does it work?

Developers use the SDK to upload and download files directly from clients. If the network connection is poor, the client is able to retry the operation right where it left off, saving your users time and bandwidth.

It stores your files in a Google Cloud Storage bucket shared with the default Google App Engine app, making them accessible through both Firebase and Google Cloud APIs. This allows you the flexibility to upload and download files from mobile clients via Firebase and do server-side processing such as image filtering or video transcoding using Google Cloud Platform. It scales automatically, meaning that there’s no need to migrate from Firebase Storage to Google Cloud Storage or any other provider. Learn more about all the benefits of our integration with Google Cloud Platform.

It integrates seamlessly with Firebase Authentication to identify users, and provides a declarative security language that lets you set access controls on individual files or groups of files, so you can make files as public or private as you want.

How to start with it 

iOS

iOS developers can download its component from here or directly add component into the project. After adding the component, Please refer the firebase storage doc to start using it.

Android

Android developers can refer github link  for its from here. For nuget package download  this.

Firebase Crash Reporting

Crash Reporting creates detailed reports of the errors in your app. Errors are grouped into clusters of similar stack traces and triaged by the severity of impact on your users. In addition to automatic reports, you can log custom events to help capture the steps leading up to a crash.

Firebase crash reporting automatically logs the crashes and you may also log custom events to help capture the steps leading up to a crash.

Key Capabilities

  1. Monitor fatal errors in iOS and fatal and non-fatal errors in Android. Reports are triaged by the severity of impact on users.
  2. Each report contains a full stack trace as well as device characteristics, performance data, and user circumstances when the error took place. Similar reports are automatically clustered to make it easier to identify related bugs.
  3. Enable email alerts to receive frequent updates when new crashes are uncovered or regressions are detected.
  4. Errors captured are set as app_exception events in Analytics, allowing you to filter audiences based on who sees errors.  In addition to grouping errors into similar stack traces. Crash reporting also integrates with Analytics to provide you with the list of events. This information helps to simplify your debugging process.
  5. Crash Reporting is free to use. Once you’ve added Firebase to your app, it’s just a few lines of code to enable comprehensive error reporting.

How to start with Firebase Crash Reporting

iOS

There is no component available for Firebase Crash Reporting !!

Android

Android developers can refer github link  for Firebase Crash Reporting from here. For nuget package download  this.

Leave a Reply

Your email address will not be published. Required fields are marked *