Logging into an App after authentication of phone number - android

So I have created an app that handles the authentication of phone numbers using firebase. Now I have another button called "Log in", I want this button to check if the any inputted phone-number is in registered in firebase and if its there I want it to go to the next screen(an intent) but if its not registered yet it should display unregistered phone number.

In firebase, each registered phone number will have a unique id. So if a user login multiple time or from multiple devices he/she will get the same id. With this, you can check wheater the user is already registered or not.
You can use functions like docRef.isExists(), were docRef is your document reference.
Hope this help!

Related

Android biometrics login

I have set up finger print login on an app, however this has caused a technical issue to arise. Traditionally the user would enter their username and password and click the login button which would verify their credentials against the record inside the database. If successful the database would return the users first name and userId which would be stored in a variable and used through the app.
Now, however when the user logs in with the finger print, there is no database transaction anymore so I don't get to pull back the user details. How are app makers working around this? When I log in with other apps using the finger print sensor the app still has to verify my account and interact with the database even without my username or password. Any thoughts on this matter would be greatly appreciated.
My solution to this was to disable fingerprint login until the user logs in the traditional way the first time. Using a boolean to track if its a first login or not. During the first login the database transaction occurs and I simply store all the users details I need i shared preferences meaning further db transactions are not necessary.
When the user opens the app for the second time they can use the finger print login from now on.

how to check when a user has phone authenticated in Firebase?

I have an Android app where users are registered in the app with their phone number, I am using Firebase to store in Authentication their phone and their email and also I am saving in the Realtime Database their phone, their full name, and their email. The structure in the Realtime Database is as follows:
Auto-Generated ID
+16505553434: "some#email.com"
email:"some#email.com"
first name: "First name"
last name: "Last name"
phone: "+16505553434"
After the user has registered and signed out when they try to use the app again I want to: if the user exists I don't want to do phone authentication again this should happen only once when they register if the user exists in the database I want to just type their password and log in. But the problem is how will I check if the user is phone registered in Firebase.
If the user has registered I want to show a layout for the input password while if the user is not registered I want to show the OtpView so that the user to do phone authentication-registration.
When the user has signed out the FirebaseAuth.getInstance().getCurrentUser() is null so i cannot use that.
What can I do to check if the user is registered or not?
After the user has registered and signed out when they try to use the app again I want to: if the user exists I don't want to do phone authentication again this should happen only once when they register if the user exists in the database I want to just type their password and log in.
When a user is authenticated with the phone number, there is no password involved. The authentication is made using the verification code that is sent via SMS. So if the user signs out, there is no way he can simply log-in using a password. He can log-in again using the phone number or any other provider.
But the problem is how will I check if the user is phone registered in Firebase. If the user has registered I want to show a layout for the input password while if the user is not registered I want to show the OtpView so that the user to do phone authentication-registration.
You can simply check your database against the phone number to see if the user already has an account. A query like this might do the trick:
db.child("users").orderByChild("phoneNumber").equalTo("+16505553434");
If you get a result, it means that the users exist. To be able to let the user "log-in with a password", you need to enable this kind of authentication. You can do it very easily in the Firebase console. But bear in mind that this is another type of authentication that cannot be combined with the first one. Check the docs regarding Authenticate with Firebase using Password-Based. So you can either sign-in with the phone number or with the email and password. You cannot sign-in with a phone number and password.
When the user has signed out the FirebaseAuth.getInstance().getCurrentUser() is null so i cannot use that. What can I do to check if the user is registered or not?
When the user signs out, the FirebaseUser object is null. There is no way you can get data from that object. All you can do it to query the database.

how to notify android app that email verification link clicked?

I have a difficult situation in mobile i need help with. I am working on a android app that allows the user to change their email address after they have successfully logged in. This is part of the account settings menu.
Let's go through the flow so i can show you the issue:
user logs in successfully as firstEmail#domain.com
user goes to account settings area and changes their email to secondEmail#domain.com.
The android app notifies the user that a verification email has been sent to their new email secondEmail#domain.com
User leaves the app and goes to their email app like gmail app and finds the verification email and clicks the link inside to verify the account.
Behind the scenes transparent to user, clicking the verification link updates the back end server to update the database with new email address.
User returns to the android app but is still logged in as firstEmail#domain.com
How can i notify the application that the user verified the email ?
I was thinking one approach could be that after user clicks on the verification link and back end DB is updated, that i could redirect them with a deep link into the app and update the new email that way but need advice as user could open the verification link from their pc or anywhere else.
Deep linking is better idea also you need to receive notification in application that email is verified and that notification you would fire or make it background by setting notification type you can do that one, so all device will receive that notification which you logged with same user.
Thanks, i hope this will work.
Log them out after they changed the account email. They should not be able to use the 1st email anymore. The account must use the 2nd one, albeit inactive until your backend is updated with verification.

how to register a facebook user in android app if the user logged in through phone number?

i am creating an android app that can register a user through social networking sites like gmail, Facebook and twitter. Now if a user logged in through his/her email id then i can register him through his email id, but if a user is logging in through phone number, and he hasn't provided any email id in Facebook, so how can i get any verified data like phone number or email id as Facebook does not gives its user phone number here and user hasn't provided any email id in Facebook (he has logged in via phone number)
Edit
this is what i've tried so far
here i use to login a user though phone number and that user is not so frequent actually so the only few details i get so far
There is no way to get the phone number of a Facebook user via the Graph API. Even not if the user set it to public.
When the user logs in from Facebook in your app you can place an Edit text which would already be half filled with the information provided by Facebook and then you can ask the user to fill the empty required fields it could also act as final confirmation of the user info and then proceed further.
Thanks

Getting Facebook user ID from message dialog

I am developing an app that would allow users to invite his friends to an event.
What I want to achieve is that when the host is inviting friends, he can invite those that are not on the app through a button. This would send a message to those invited friends that includes a link to install our app. Once they install the app, they can login and will immediately view events he is invited to. Can this be done?
The concern is that when the user who receives the invitation message and installs the app and logs on, how will the app know the person who logged in is the person that is invited in the first place? If the app cannot associate them, how can we provide the relevant events to him once he has logged in? Is what I want to achieve unattainable?
I think it might be done through the old Facebook API, but their new one will only allow an app to access a user's friends who are also on the app and not those that are not on the app. In this case, is there a way for us to pull the UID of those invited through FB's messaging dialog? And will this work with group chat?
I know that another way will be to do it via phone number confirmation and accessing the user's contacts, but I want the invitation process to be through facebook if that is possible.
Thank you all for your help in advance.
Lok

Categories

Resources