Firebase Authentication get mobile app users - android

How to export users who have downloaded the mobile apps?
Firebase can export the list of Authenticated users but there seems to be no built-in way to get the users who have downloaded the mobile apps:
https://firebase.google.com/docs/cli/auth
-- My specific use case --
I want to give a free purchase ticket only to the first 5000 +- users who have downloaded the apps.

Firebase Authentication has no built-in way to track from what platform a user accesses your app.
The closest I can think of is to set the user's ID in Google Analytics for Firebase, and track the platform there.
The alternative would be (as Joshua commented) to have the native apps write a for for each user to a database (like the Realtime Database or Cloud Firestore). If you choose this approach, you'll have to find a way to secure that write though. Here too Firebase doesn't have anything built in to only allow writes from certain platforms, so it's up to you to come up with a security scheme.

Related

Is it possible to know if firebase auth is from android app or iphone app or web app?

I wanted to know if when there's an firebase authentification, it's possible to get the source of this authentification?
To know if it's from my iphone app, android app or web app.
Why :
My web app isn't on the web, but on local server. I want to distribute this web app with server (It's for a personnal project but it could have 10 prototypes). So everybody can get my firebase config. And I don't want that someone can create account from the web firebase api because I accept google/apple and email/password auth. I can't disable email/password for my project purpose.
I hope this is clear.
To be more clear, if the email/password auth is created, is it possible to know if it's from android app or iphone app or webapp?
Thanks
The provided APIs for Firebase Auth don't give any indication which platform was used to create the account. Firebase intends for all accounts to work across all platforms using the provided SDKs and APIs accessible for each platform.
If you want to record your own per-user data in a database, you're free to do that. Note that this is not really "secure" in that each user could effectively manipulate your database or APIs to indicate whatever they want about their platform. If you do not have this sort of security in mind, then you can simply trust your own code to write, and late read, the user's platform in a database after they sign up.
To be more clear if the email/password auth is created, is it possible to know if it's from the Android app or iPhone app, or web app?
Yes, it's possible. Let's say we want to know if a user has signed in from Android. When the user creates an account from an Android device, most likely you are storing user data as objects in the database. The simplest solution I can think of is to add another property in your User class, called "platform" and set it to "Android". If the user signs up with an iPhone, then set the property to "iOS". Same thing for the web. Knowing that the user might change the device, every time the user opens the app check that value against the OS the user is using. If the OS is changed, also change the value accordingly. This way you'll always know the OS the user is using. If you allow the users to use multiple platforms, for Android, there is a function called getProviderData():
Returns a List of UserInfo objects that represents the linked identities of the user using different authentication providers that may be linked to their account.
Similar functions can be found for the other platforms as well.

should I connect to firebase on the front-end or the back-end?

Im currently building an app, back-end and front-end and I use Firebase for saving pictures that the users can upload and download, up till now I've been uploading them from the front-end and if the upload is successful then I send the image link with the rest of the data to the back-end, but as Im saving firebase credentials (in order to connect) in the app, now Im questioning if it would be better/safer doing it all in the back-end, sending all the information (image included) and the let back-end upload the image to firebase. I don't how how secured are those credentials being of the app
I usually handle things in the front-end if the Firebase SDK has what I need. The only common reasons not to do this, is when there is a requirement to do them in the back-end. This is only common for operations that: require a lot of memory/CPU/bandwidth, require access to secret information (e.g. an API key for a payment gateway), or where the code itself is secret (e.g. detecting cheats in a game, or malicious messages in a chat app).
In your case for example, uploading directly from the front-end to Cloud Storage is a great reason to use the Firebase SDK. Doing so means that Firebase takes care of the encoding, of retrying, of security, and many other things. If you'd want to introduce your own server in the middle, you'll have to write the (client and server) code to handle all of that yourself.
Note that the keys that Firebase tells you to add to your app through the google-services.json are not credentials, but merely configuration data that the app needs to find your Firebase project on the servers. For more on this, see my answer here: Is it safe to expose Firebase apiKey to the public?
But that said, with the configuration data anybody can call Firebase API methods on your project. So you need to secure access in some way, to prevent other users from coming up with their own code that uses your project.
The common way to do this is by using Firebase Authentication on the client to sign the users of your app in. You'd then use the Firebase security rules to limit who can read/write what files in Cloud Storage.

How to store user data in cloud for free from my app?

I am writing an Android application in which users will have personal data (and only personal data). I would like to have some way for them to store it in the cloud without me paying, for example, so that their data is stored in their Google Drive (though not necessarily accessible through Google Drive UI). Is there an easy solution for this?
I had a look at Firebase, but it seems that it has 'common' data storage, which would be associated with a developer's (that is mine) account.
You can use FireBase. It's a great platform to host your app content
https://firebase.google.com/
you could create a database to store the data, but you'll require to keep a server running 24/7 if you don't want to pay for it. Also I don't see the drawback of associating the user data with your account as long as you don't rat out yourself.

Optionally using Cloud Firestore in an app

I have an app that uses SQLite to store the users' data (stats and such). The app doesn't require users to sign up or log in. I would like to add the capability for cloud syncing of data to the app, so Cloud Firestore sounds like a great fit. However I don't want to force users to sign up or log in if they don't want to use cloud syncing features.
Is there some clever way to use Firestore locally without having to log in users? That way I could convert the SQLite data to non-relational format once and have one place where the data is stored. Otherwise I'd have to maintain and update two databases - one for users who don't want to sign up/log in, and another for those that do.
Cloud Firestore doesn't require users to sign in. You can easily use Firestore without having the users sign in. I do this all the time, since data in my apps is often simply shared between all users without any sense of ownership.
However: finding a user's data in a cloud-hosted database requires that you're able to identify the user. If you already have a way to identify them, then you can continue to use that identification with Firestore.
If you don't currently have a way to identify users, I recommend looking at Firebase's anonymous authentication. This is a completely transparent, non-interactive way to add a user identification token.

Shared(common) data storage and communication in android app

Say we have an ongoing token number for queue which is to be shared(shown) among various users who have downloaded that particular app.
Question is:
Where should that common/shared token number be stored? Also which database should be used?
Does this require server setup? If yes, is there any alternative to that?
And how to make that token number accessible to various users of that app?
You will likely need a server to deal with that.
If I were you I would work with Google Cloud. You can very easily integrate App Engine / Endpoints into your Android Apps if you use Android Studio.
Use Google Cloud Datastore
Use Google Endpoints
Share the token through an API of some description - any updates to users can be made real time using Cloud Messaging

Categories

Resources