I have build an anroid app which uses firebase where in i send my data. I have a form in my app. the data from the form is sent to firebase. If two users are entering the data simultanously, and one of the users update the data first, the filled data in the other user's form is cleared. I need a solution to this issue. How can i avoid data being cleared from other users forms?
You need to implement transaction operations. Linked documentation here.
If you need per-user storage in the database, it doesn't make sense to store everyone's data in the same location in the database. Instead, use Firebase Authentication to get your users logged in with a unique user id, and use that user id to store user data in a dedicated location in the database.
Related
I have an app, that on the first start generates a random user id and password to set up an account on my server and store them in the shared preferences.
I am looking for a way to write this data into the cloud so that if the user installs the app on a second device it will retrieve this account data and use them on the second device as well.
On iOS, this is a trivial task but I am still trying to figure out how to achieve this on Android. I tried an approach with Firestore, but it seems to be able to write to the Firebase database, the user has to log in with Firebase. I assumed being logged in to a Google Account on the device would do this, but I still get invalid permissions back when writing data.
I do not want to force the user to a separate login.
Any ideas on how to approach this task? Is it possible on Android at all?
I have an app, that on first start generates a random user ID and password to set up an account on my server and store them in the shared preferences.
If you have your own server where you authenticate the users, and you also want to authenticate to Firebase, then I recommend you check:
Custom Authentication System
I am looking for a way to write this data into the cloud so that if the user installs the app on a second device it will retrieve this account data and use them on the second device as well.
You just should never simply store the credentials in Firestore. Storing passwords in cleartext is one of the worst security risks you can inflict on your users. You should either use authentication with your custom system or use one of the existing providers, like Google, Facebook, etc.
I tried an approach with Firestore, but it seems to be able to write to the database, the user has to log in with Firebase.
It's recommended to authenticate the user in Firebase before reading/writing data from/to Firestore because you can secure your database using Firestore Security Rules.
P.S. Don't store data in ShartedPreferences because this type of data is stored locally and doesn't persist application uninstalls.
I wonder how to do user management using Firebase. I have completed the implementation of the authentication process using firebase auth, but is it developed in a way that additionally stores user information in Firestore to perform a user search function? I wonder if general users can use the user search function using the Firebase auth SDK.
Also, I'm curious about how the user operation on the client-side using Firebase is currently performed.
You can only register or verify the user using auth service and if you want to search user you have to store user data in real-time or firestore.
When Firebase auth is processed, user information is also recorded in Firestore. I was wondering if this method is correct.
Yes, that's correct. That's actually a common approach when it comes to storing user data. Once the user is authenticated grab the corresponding data and store it in the database. You can either use Firestore or the Realtime Database.
I was wondering if it is possible to get user information from the auth function and manage users more efficiently.
I'm not aware of a more efficient way of doing that.
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.
I'm working on the application using Firebase Realtime database. App is live but I see problem with users that they don't want to login (so I'm losing a lot of users because one of first screens is login screen).
I'm thinking to update my app to be able to work without login and when user decides to authenticate then I would send his/her data into cloud and continue working as usually.
What is (on your opinion) best approach? Should I create JSON nodes something like sessions_unauthed with random uuis for not logged users and sessions for logged users. And move data from one subtree to another when user login?
what you can do is that you can use anonymous login function of firebase and storing that uid to sharedpreferences and then moving those nodes to the newly logged in user's uid nodes.
Hope this helps
I am using Parse.com with android backed app and wanted to store some of data specific to application not user's data.
So, is there anyway I can accomplish this without login in any user & store data which belong to app not user.
Sure.. You can create and query objects on Parse regardless of whether you're logged in or not. You can also call cloud functions.
I would recommend using a Cloud Function, locking down the security of the classes you're using to store the data, and using the Master Key in the cloud function to access/write to the data securely.