Swift, I want to get phone number(not udid) and email from device [duplicate] - ios

This question already has answers here:
Programmatically get own phone number in iOS
(9 answers)
Closed 7 years ago.
all
I'm developing app and it contains function which gets phone number and email from device.
I've looked at some samples on internet but all of them are about unique id.
How can i get phone number and email from device?
Is there anybody who has experience in this area?

Apple has removed access to this data from inside your app. You may not access the user's phone number from the device. You instead must require them to enter it in a text field or something.
"For security reasons, iPhone OS restricts an application (including
its preferences and data) to a unique location in the file system.
This restriction is part of the security feature known as the
application's "sandbox." The sandbox is a set of fine-grained controls
limiting an application's access to files, preferences, network
resources, hardware, and so on."
The device's phone number is not available within your application's
container. You will need to revise your application to read only
within your directory container and resubmit your binary to iTunes
Connect in order for your application to be reconsidered for the App
Store.

This is not possible from the iOS APIs, you will need to query the user for phone number or discover it through other means.

Related

Ionic getting iOS device number [duplicate]

This question already has answers here:
Programmatically get own phone number in iOS
(9 answers)
Closed 5 years ago.
I have been looking a bit around for a way to retrieve the phone number of an iOS device but without too much sucess as I've seen mixed reports
According to this link it's a no :
Programmatically get own phone number in iOS
Also here https://www.npmjs.com/package/cordova-plugin-sim
I don't see any information about the phoneNumber for iOS.
However, as these links aren't brand new, I would like know if things have changed since
You can't. You should ask user for phone number from UI.
First of All, its impossible to get Phone number in iOS programatically. iOS don't allow such things. You can get the carrier name of the mobile number.
If you really want to get the Mobile Number, then you have to ask the user to send a message on a number which will be configured with your backend service. Once the message reaches to the number in Your backend System , you can get the mobile number from the backend with a Service call.
NO, this not possible as Apple wants to respect the privacy of their users. You can't access the phone number from public API, so you cannot.

How to read Phone number in iOS 10.1.1 - Objective C/Swift

I have saw so many Questions regarding this on SO. All answers say that it is not possible. Apple doesn't allow to do so.
I am using iPhone 6s running on iOS 10.1.1
Yesterday I purchased new Sim Card.Just after inserting my new SIM when I opened WhatsApp. I get a Screen which says:
`Your number has been changed. Do you want to use new number`
How does whatsapp able to do so?
Secondly I installed Airtel App. When I opened the app. It automatically fetched my phone number And Displayed to me.
How these apps are able to read phone number.
Is apple added new methods in iOS 10 or they are using some other logic to do so.
There is an observer subscriberCellularProviderDidUpdateNotifier
as per the docs here
A block object that is dispatched on the default priority global
dispatch queue when the user’s cellular provider information changes.
This occurs, for example, if a user swaps the device’s SIM card with
one from another provider, while your application is running.
To handle changes in cellular service provider information, define a
block in your application and assign it to this property. The block
must be implemented to support being called from any context.
That just notifies you that your sim has been changed.
Regarding your second question you can get the number from contact app using Contacts.framework
There are some changes in privacy in ios 10. A new key you have to add into plist file if you want to access contacts database in your app.
<key>NSContactsUsageDescription</key>
<string>$(PRODUCT_NAME) want use you contacts</string>

How to get "My Number" from AddressBook framework ? [duplicate]

This question already has answers here:
Programmatically get own phone number in iOS
(9 answers)
Closed 7 years ago.
I need to retrieve "My Number" from AddressBook but I can't find out how to do so. When accessing the contacts in AddressBook, I managed to get all the contacts but I don't know how to get the "My Number". I know it's accessible as for instance on my phone, it is categorised under my first and last name and therefore I manage to take it from there. But I would like the standardised way to access the "My Number".
Thank you infinitely for your help,
This is not allowed. There is no public API to get user's phone number.
There are few open question on SO that cover this theme. For example this.
"For security reasons, iPhone OS restricts an application (including its preferences and data) to a unique location in the file system. This restriction is part of the security feature known as the application's "sandbox." The sandbox is a set of fine-grained controls limiting an application's access to files, preferences, network resources, hardware, and so on."
The device's phone number is not available within your application's container. You will need to revise your application to read only within your directory container and resubmit your binary to iTunes Connect in order for your application to be reconsidered for the App Store.

Detecting Phone numbers in iOS App

I am developing an iOS app, where I would need to access the phone number of the user logging in, query the DB to check if the phone number exists as an entry & finally display an alert to the user. Is it possible?
Read Apple response on this kinda app rejection..
"For security reasons, iPhone OS restricts an application (including its preferences and data) to a unique location in the file system. This restriction is part of the security feature known as the application's "sandbox." The sandbox is a set of fine-grained controls limiting an application's access to files, preferences, network resources, hardware, and so on."
so its not possible to read the user number by your application, best way to ask him to enter and validate at your server end!
More detail about SandBox here
It's not possible to detect phone numbers from an app.
However, there are solutions that allow phone number verification (after the user inputs his phone number) by placing missed calls.
I have used such a solution provided by an India-based company named ZipDial.
Check the section titled "Mobile Number Verification" in the link above.

Can I get user's phone number by requesting for permission in ios 6? [duplicate]

This question already has answers here:
Programmatically get own phone number in iOS
(9 answers)
Closed 9 years ago.
I am building an IOS6 app which requires the user's phone number,
Is there a way to ask the user for permission and get the number in programmatic way?
Or he has to manually type it in?
I am using Xcode 4.5 if it matters..
You can't get the phone via any easy API within iOS. There might be a way to do it via the technique described in this related question, but this is a few years old and Apple may have closed this hole (which uses an undocumented key). I also wonder if Apple wouldn't allow the app on the App Store for privacy reasons. Probably not.
You'll have to trust the user to type in the correct phone number if you prompt him/her to.

Resources