I am using smartphone authentication feature from firebase to register my users, but some of my users do not receive SMS codes in their mobile phones(signal problems...), and sometimes i really need these customers, so i create a test SMS code (using the real phone number, so they can receive SMS in the future). When they authenticate with the fake SMS Code, firebase create an ID with an UID and i can login again later with no problems, but happened that 3 times these users created with the fake number feature and with an valid and registered UID were deleted from the authentication list after some time, i cant find them anymore, and when i register them again, a new UID is generated, is this a real behavior of firebase, exclude test numbers UID generated after some time?
Related
I have setup a firebase project to track users events and for supporting push notification in my IOS and Android apps. In my apps I was registering for notifications when user completes sign up. However I have a number of users who just opened the app and didn't complete registration. I am planning to send notifications to such users to give them a nudge.
However I don't have the notification tokens for such users in my database. So is there any option to export the details of such users from firebase where I can grab their notification tokens?
I tried using big query and audiences but that wont work with historical data.
It sounds like you're using FCM tokens to send messages. In that case you will always needs an FCM token to send a message to a specific app/device.
FCM doesn't know anything about users of your app; all it knows about are the tokens.
So if you want to send a message to an app instance where the user didn't sign in, you'll need to store the token from the app in your database as soon as the app starts - even before the user signs in. Then when the user signs in, you can associate the token with their UID.
With those steps out of the way, you can query for database for tokens without an associated UID and send them a reminder to complete the registration.
In a classroom, I'll provide to 100 users, 100 android devices, where they'll have to open an UNITY app.
Inside the app, I don't want the users to bother to enter any login, any email, any password.
So I guess they would need to be connected "automatically" to the same firebase account.
Then, they'll need to select one of the avatars available in firestore, with which they'll play and the app will save their avatar progress in firestore.
Is it possible to have so much players and devices using the same firebase account at the same time for that purpose ?
I'd probably first look at signing in each device anonymously. That way each device/app instance has a unique, persistent identifier, without having the user enter any credentials.
You can then also use the UID in your database to have indicate the avatar that each user/device claims, and in the security rules of that database, to ensure users can only access data they're authorized for, and for example that each avatar can only be claimed by one user.
in the app, which logs the user in only through phone authentication.
now the question is can I get the user id from his phone number(not the user id of the current user though).
I have the access to other users phone number in the app, and I want to get their id for further use.
is it possible in flutter with firebase at the backend?
Looking up the UID for a user based on either phone number or email address is considered a sensitive operation. For this reason such operations are only available in the Admin SDKs, which are designed to be used in trusted environments, such as your development machine, a server you control, or Cloud Functions. For more on these, see the bottom two code samples in looking up user data in the documentation.
If you want to perform such operations from your client-side code, your two main options are:
Store the required mapping in a cloud-hosted database, such Firebase's Realtime Database or Firestore, as Huthaifa also answered.
Create your own custom API on a server or Cloud Functions where you lookup the user through the Admin SDK. Your client-side application code can then call this custom API.
In both of these cases you are in full control of what data you share, and how you secure access.
Sure you can, there are multiple approaches for this, if you post your structure for the user model, or how you are storing them in firebase.
You can run a simple Firebase query like this example:
FirebaseFirestore.instance.collection('users').where('phoneNumber', isEqualTo: thePhonenumberOftheuserYouwant2GetUIDfor).get()
You can also store the available\accessible contacts for every user in their user document, and when your user logs in, it'll fetch all their allowed user numbers.
The more information you provide to your problem, the more StackOverflow can provide you back.
Firebase allow free 10k authentications/month + 0.06 per each extra authentication. I am reading a documentation however it is still not clear to me what authentication/validation definition is.
Does that mean I can receive 10k free sms messsages per month and I will pay nothing extra when user already logged in and uses APIs to call firebase services OR it means I will need to pay extra even after user successfully logged in but in case of firebase internally wants to validate authentication status as kind of a background task is considered authentication too?
In other words: let's say each month I have 10k new logins (sms received) should I expect to be charged anything extra?
Firebase Auth only charges on successful verification.
So if a user tries to sign in with a phone number and an SMS code is sent but not used or received by the user, this attempt will not be counted. Only when user enters the code and successfully verifies it (successfully signing in), will that attempt count. The first 10k successful verifications are free. Any successful verification afterwards will be $0.01/verification for US/Canada/India and $0.06/verification for other countries.
My usecase it to send a push-notification to a user using the Firebase Auth UID to all the devices he is signed-in. Since firebase Auth is managing the user sessions,
Is there a way to directly send a FCM notification just using the uid of the user? Or
Is there a way to fetch the registration ids of all signed-in devices for a given uid?
This looks like standard requirement, for example to update the 'Order Status' to a user. If available this could be pretty powerful, and could greatly simplify direct messaging requirements (e-commerce, chat etc) where the user gets notified on web/android/ios.
If this is not possible, any suggestions on the standard way to acquire/manage the registrations_ids of a given user is appreciated.
Thanks all,
This is not supported out of the box but you can build the mechanism.
You need to maintain a uid specific deviceGroup and all the registration ID per device that belongs to it.
Each time a user signs in with Firebase, you get the device registration ID and the user's ID token and send it to your backend. You verify the ID token and get the uid from it, you then add that registration ID to that user's device group.
Each time a user signs out, you remove their registration ID from the signed out user's device group.
When you want to send a push notification to a specified user, you can send it to the user's device group ID.
This is the simplified version but there are a bunch of edge cases you have to deal with to keep the device group for a user in sync so no notification is sent to a signed out user.