IOS: How to verify user's phone number using codes - ios

i am working on an app in which i take a field of mobile number of user after entering mobile number there is a option for verify phone number.
but i don't know the functionality of how to verify a user's phone number within the app using codes.I search for similar type of questions but didn't get the exact solutions.
i am sending a screenshot of my app where i want to put that functionality.
i didn't apply any codes for this
please help

You need a backend that can generate and save codes for each phone number and also send a text message with those codes. So the flow is as follows:
User enters their phone number in the app and presses the "Verify Number" button.
You send a request to your backend with the number provided. In the app, you also displays a text field for user to enter the generated code and a new button like "Check code".
The backend generates a new code (just a random one), stores it to the database (like ID,PhoneNumber,GeneratedCode,DateOfGeneration) and sends a text message with the code to the phone number specified.
When the user receives the message he or she enters the code to the checking input field and presses the "Check" button.
The mobile app sends another request to the backend with the phone number entered earlier and the code entered by the user now.
The backend looks to the database for the "Phone number" - "Code" pair and responds with failure (the code is incorrect, try again) or success (the phone is verified).
Unfortunately, there's no way to access text messages received by user from within an app on iOS devices (unlike Android). The proof link was already provided. So the user has to manually enter the verification code from the message.

Ok I tell the information how was I already did my project in before
Step-1
when user press the Verify Number button
initially I check the phone number is valid or not(means phone number count/length).
second I generate the random number on progrmatically like NSUInteger r = arc4random_uniform(16);
Step-2
send the random number to server along with the vaild phone number , the server send the random number to the particular mobile number using SMTP Server.
Step-3
in your hand you have the random number , so open the UIAlertview for user type the valid random number , if user typed the vaild number show the Next Screen else show the Alert.

To verify any mobile number you can use third party api's which are available for mobile as well as backend server. You can use Twilio Messaging Api. To use this API follow below steps:
Register account on Twilio and get key from account.
Get user's phone number from mobile application.
When user click on the "Verify Number" button, call web-service with the number.
When you'll call the web-service, write a logic to send the random number with the Twilio messaging api to send message to user.
When user get this number through SMS, You can tell user to enter the number and verify it.
Also, there is another api which you can directly integrate into your mobile application. You can find this Sinch Api here.

To verify against your device's phone number, first, you need to get the phone number from your device and then you can compare against. However, after iOS 4, getting phone number of your device is quite impossible. Even if, you do get the device's number using some private api which I am not sure works entirely, there is a huge possibility for Apple to reject your app.
Refer to the following stack overflow discussion-
Programmatically get own phone number in iOS
Just a suggestion: You probably want to look for a work around based on your business goal. For example, rather than checking for device's phone number directly. You can generate a code and send that to the number specified by the user and then enter that code to verify that the user has that device.

Related

Typeform Phone Number value to Zapier

I’m trying to build a form that asks users for their phone number, then automatically sends them a welcome text to them once they enter it.
Zapier can’t seem to find the phone number value from Typeform. Is this doable?
If it helps, I’m integrating with SimpleText to send the message, which works fine when I enter a phone number manually. Just can’t seem to replace that with the phone number values that come out of the Typeform.

Authenticate with Firebase using Phone Number iOS

I have to create a sign up phone number option in app and I am getting a little confused when it comes to phone number/verification textfield and whole interface controller. Do I have to create this on my own or firebase auth is supporting this screen as it happens in digits?
firebase docs: https://firebase.google.com/docs/auth/ios/phone-auth
You have two solutions, one would be to use their UI:
https://github.com/firebase/FirebaseUI-iOS
The second one would be to create the UI on your own and just call methods mentioned in the link you shared:
verifyPhoneNumber (which returns the code)
credentialWithVerificationID (creates verification object)
signInWithCredential (accepts the verification object and tries to sign-in)
Basically, you want to get the user phone number in order to receive the code(most likely from a textfield). Once you successfully sent the code. transition to a view where the user can enter the code received thru sms than login the user. keep in mind the phone number format has to be something like this +countrycodeStatecodeNumber or +13051239988

How do I Generate a Text Message to a Predefined Phone Number in iOS 10?

Let's say I have the user of my app define a phone number in a setup step of my program, saved in the plist as a number with the key "PhoneNum". Now lets say that I want to have a button in the program which, when pressed, generates a text message that says "Hi! How are you today?" to the phone number saved under "PhoneNum". Is it possible to have this message auto-send without confirmation from the user? If so, can you point me in the right direction?
Yes, it's possible, if you pay for an SMS-sending service. Type “sms sending api” into your favorite search engine.
If you want to send a message through the user's own iMessages or cell phone account, then you cannot do it without confirmation. How to programmatically send SMS on the iPhone?

How to send message for registrarion processing

I want to know how to send the message to a particular number when he entered his number.
how the registration process going?
My question is.
1.user enter his mobile number
2.he/she hit the registration button
then i need to send the message(some random code granted by server-php side)to that number.
for this i need web service ?
you can do this alternate way but with out web service you cant do this
Reason : user has use the more than one Device, he given the alternate number of another device , you can't handle
Choice-1
Step-1
inside your app create the randomarc number and when user hit the registration button send the random number with your profile details to backend with the help of webservice.
Step-2
In backend side with the help of SMTP in which random number you already send to backend , the backend developer send the random number to particular mobile number.
Step-3
finally In your own hand your random number number is available , in here no need of webservice ,if user entered the same number move the next step else show the alert thats all.
Choice-2
Step-1
when user hit the registration button send the profile details to backend with the help of webservice and get the random Number on success response.
Step-2
In backend side with the help of SMTP the random number to particular mobile number.
Step-3
finally In your own hand your random number number is available , in here no need of webservice ,if user entered the same number move the next step else show the alert thats all.

Making a faux iPhone dialer

I want to make a joke application for a friend (not for general sale) that looks exactly like the iOS Phone application but so that whatever number is dialled into the application it appears to dial that number but actually dials a preset number in the background.
The way I figured to do it would be through the following:
User enters a number and hits the call button
Save the number entered as a contact's name and programmatically set the number of that contact as the preset number
Get the application to ring the preset number, to which it would switch over to the real iOS phone application and dial, but with it being a saved number in the contacts it will display the name, which is the number entered by the user.
Delete that contact upon re-opening the application as for it to not ask which number to dial the next time.
This is the only way that I can think of pulling this off, but it seems like it will look unconvincing; especially when it switches over to the real Phone application. Can anyone think of a better way? Such as calling from within the application?
I wouldn't usually take junk requests like this but it made me curious as to pull it off best.Thanks
If you are not going to publish this, then there is no reason why you shouldn't use private apis. See this answer (How to directly make a phone call with private API CTCallDial()?)

Resources