Firebase with architecture components - firebase

I am looking for advice on how to use android architecture components and firebase.
I am new to android programming and I've heard of architecture components and how it makes it easy for beginners to get started with android. I am using firebase realtime database as my backend.
Should I place the database calls like addListenerForSingleValueEvent in the repository class or its okay if I use it inside my activities and fragments?
I have searched for guidance on how to use firebase with the android architecture components but haven't found any. Any best practices on how I can use firebase with architecture components?

Have you taken a look at this Firebase Blog post Using Android Architecture Components with Firebase Realtime Database

Related

Is Firebase App Check available for Unity, Godot, or other game engines?

I am about to start making a game for iOS/Android which involves connection to Firebase backend.
Since the game contains a bit controversy theme, I'm scared of DDoS kind of attacks.
To make protection, I know Google provides Firebase App Check service and they say it's available for iOS/Android/Flutter/Web according to their webpage.
https://firebase.google.com/docs/app-check
My question is, is the service available for Unity, Godot, or other game engines?
Since App Check SDK is available for Flutter, does this mean we need SDK for Unity, Godot etc. if we use those engines?
Or can we just use Firebase iOS/Android SDK together with any game engine?
I checked whether they provide SDK (with App Check) for any game engine and only found that Firebase Unity SDK seems to be trying to implement App Check feature (but not done yet).
https://github.com/firebase/firebase-unity-sdk/issues/511
It would appear Firebase is available in the Play Core Native SDK, so it would be possible to use GDNative to access the API.

Create and configure Firebase project programmatically

I am building an automation process for my app, which includes creating several new Firebase projects. (After a lot of investigation, I am sure that several projects are needed, and that it cannot be done with just one project).
I am looking for a way to create a new Firebase project from scratch, and enable Phone Auth, Cloud Firestore, and Cloud Storage, along with security rules, programmatically.
I have taken a look at the Firebase Management REST API, which indeed shows a way to create a new Firebase project and link it to an existing GCP project, but couldn't find a way to configure the project itself through the API (Authentication, Firestore, Storage, etc.).
Is there any way to create and configure a Firebase project from scratch, using an API/SDK or CI/CD of some kind?
Thank you!
Have you looked into the firebase-admin SDK? It is a backend-only API because it needs your private key to authenticate against and can therefore not be used in the app directly (shipping your private key with the app would be pretty big security issue!), but as I understand it, creating new firebase-projects is something of a backend activity for you anyway?!
Look at https://firebase.google.com/docs/auth/admin/ for the API's documentation and what you can do with it.
So after a long research, it seems that we can combine the Firebase CLI and the Firebase Admin SDK in order to achieve it.
We can create a new project using the command
firebase projects:create NEW_PROJECT_ID
And then to configure all of the necessary configurations through the admin SDK

Can you use Firebase on a non-yet built mobile app?

I am planning to use Firebase for the backend of a mobile app project, and I was wondering : am I obligated to build an app to be able to use Firebase (e.g for tests) ? Or is there a way to use Firebase during my programmation phase ?
Firebase offers about a dozen of services. Including databases and test tools.
You can use any subset of those services
You can use Firebase any way you want using the provided APIs and SDKs. This might or might not involve a mobile app. As long as you stay within the limits of the free tier, or are willing to pay for the services you consume on the Blaze payment plan, nobody will care if you have an app or not.

flutter & cloud firestore for web, ios, web

I want to develop a flutter app for android, ios and web. My idea was to use flutter so that I can build all of those three components with the same source code. As a DB I decided to use cloud firestore, as I thought that it would have the easiest flutter integration. For android it works great, however for web my code seems unusable.
I came across this plugin list, and it seems the only plugins available also for web are firebase_core and firebase_auth:
https://github.com/FirebaseExtended/flutterfire#available-flutterfire-plugins
So now I have the following questions:
What can I do with the firebase_core plugin? Can I access my firestore DB? (There seems to be no real documentation..)
To learn what you can do with the firebase-core plugin, have a look at the sample app for it.
Mostly it allows you to create FirebaseApp objects, which you need to create any of the other Firebase service objects (such as FirebaseAuth). So while you can't really do anything meaningful with just firebase-core, it is a prerequisite for most other Firebase services.

Expo and react-native-firebase

I'm trying to integrate Firebase into my expo app using the react-native-firebase framework which has several advantages over the regular firebase package when it comes to react-native apps.
However, I'm running into difficulties since the instructions say I must add the GoogleService-Info.plist to ios/[YOUR APP NAME]/GoogleService-Info.plist, and expo apps don't have an ios folder from what I understand.
Am I pretty much screwed or is there a solution for this?
As the react-native-firebase documentation says, you need to eject your app if you want to use this library with expo. Be mind that eject action is not reversible. More info here and here and here.
If you use Expo and would like to use this package, you'll need to
eject. If you do not want to eject, but wish to make use of features
such as Realtime Database (without offline support) & Authentication,
you can still use the Firebase Web SDK in your project.
Today, you can't have the Firebase react-native sdk with expo. And this is not planned according to: https://expo.canny.io/feature-requests/p/full-native-firebase-integration.
So you have to play only with the javascript sdk from Firebase.
Cloud Firestore is new, it will be better for the javascript sdk for offline and sync.
The author of this thread: Fresh Detached Expo + RNFirebase not running on Android has managed to get it working with the Detached ExpoKit - so it's not a full ejection and keeps the expo features.
I have asked for the steps he took so we can see about getting something added to our docs and possibly a Detached ExpoKit version of our starter app.
See the expokit detaching docs for information about ExpoKit.
It's in progress --
https://blog.expo.io/using-firebase-in-expo-e13844061832
Using Firebase in Expo
And how we plan on adding it to the client 😁
We are super excited to announce that we will be rolling out a suite of Unimodules that will provide you with easy access to native Firebase features! initially you will only be able to use these in a detached ExpoKit App. But over time we will be working to add these to vanilla Expo.
TL;DR
Here are the modules, you will need to detach to add them for now:
App/Core
Analytics
Authentication
Cloud Firestore
Cloud Functions
Instance ID
Performance Monitor
Realtime Database
Cloud Storage
Remote Config
Firebase Cloud Messaging
Remote Notifications
Dynamic Linking
Invites
Crashlytics
Also TL;DR
Here is a boilerplate: https://github.com/EvanBacon/expo-native-firebase
Update 02-12-2021
Guys expo's eas-build is now public. You can add custom native codes and use react-native-firebase. Here is the link to a youtube tutorial. The video is short and super easy to follow. Here is the link to the docs
Previous answer
If you are using Firebase using the mobile configuration, it does not work, but it worked smoothly when I tried the web configuration. Here is the youtube tutorial. Watch from 38:20 to set up.
I managed to get a working set of react-native with redux, firestore and expo. See Code example at Github.
But it costs the offline-persistence (see https://github.com/firebase/firebase-js-sdk/issues/436). So from my point of view it costs performance, because i need to be online to get a full working app with firestore and react-native.

Resources