How to get IMEI and phone number

Hi everyone.
I need to get the iphone number and the IMEI number of the phone where an App is running.
Anyone knows how to ?
Thanks.

Before iOS7 it worked through CoreTelephony but as far as I know (please correct me if I am wrong) this was axed by design because of privacy concerns.

The user’s phone number is not available within your app’s container.
(Meaning you can’t get the user’s phone number)

I did find this http://stackoverflow.com/a/11954786
But at that point you might as well just ask the user for their phone number.
(which, by the way, is much nicer in terms of UX and privacy concerns)

Thanks for your answers.
For the pourpose of my App there is a must that the app by itself obteins the IMEI or the phone number of the device.
I hope there is a way to get it

[quote=275271:@Mariano Poli]Thanks for your answers.
For the pourpose of my App there is a must that the app by itself obteins the IMEI or the phone number of the device.
I hope there is a way to get it[/quote]

If what you want is to recognize a unique marker on the phone, there may be other ways to get a unique number, like fetching the MAC address. Unlike under OS X, there is AFAIK no way to spoof that, as it is quite off limit to programmers.

Otherwise as Tim suggested, your best bet is simply to ask the user.

You can’t get the MAC anymore.
http://stackoverflow.com/a/20902339

The general idea is that you can’t get tracking information that could be shared. It sounds like you can get a unique identifier for your app with [UIDevice identifierForVendor] because it would be different for each app.

Thanks Tim and Michael.
Let me explain a little bit more about my needs.
My app will generate QRs with some information inside.
I need to include not only that information in the QR but also some phone´s ID that let me know, reading the QR, which specific phone had genereted it.
The ID may be the IMEI, the phone number, or any other information that identifies the phone where the QR was generated.
One way could be of course to aks the user to place the phone number when starts the app for the first time, but this will let him to enter the real number or any other.
I hope I explain it well in my “particular english”
Thanks again.

It sounds like you’re trying to identify a user whether or not they want to be identified. This is exactly what Apple is trying to protect against by not allowing you to access those details. From what I’ve read you can get a unique identifier for the user using your app, but it will not allow you to figure out who they are. For this you can use [UIDevice identifierForVendor] (you will need to create a declare to use that.)

You may need to set up some kind of unique authorizations server that interacts with [UIDevice identifierForVendor] because as a developer you don’t have access to uniquely identifying information about the user.

You could use a sms service which sends an control/activation code. That way you identify the device/user in a correct manner. Store it somewhere safe with a device GUID and you have the unique user.

Request the user to confirm their cell phone number, then send a code (unique), let them enter it in the app and check it online from a service/api you created.

[quote=275287:@Mariano Poli]My app will generate QRs with some information inside.
I need to include not only that information in the QR but also some phone´s ID that let me know, reading the QR, which specific phone had genereted it.
The ID may be the IMEI, the phone number, or any other information that identifies the phone where the QR was generated.
One way could be of course to aks the user to place the phone number when starts the app for the first time, but this will let him to enter the real number or any other.[/quote]

Apparently you want to make sure the data comes from a particular phone and not another.

Seems to me the UIDevice identifierForVendor may suffice, as it ties the data to a particular instance of the app corresponding to the phone it is installed on.

Otherwise you are in to ask the phone number.

Looking at Apple’s docs, the UUID that’s returned is unique to the Vendor on the device. That way if you have multiple apps on a device, they all get the same value for this method call.

The other way would be to create a unique identifier and store it in AppData.

Sounds like its exactly right EXCEPT if it came from an enterprise app or from one still in development
Then its calculated off the bundle ID as noted

Otherwise its from App Store data

But its for identifying the device - not the specific app (for which it already can get its own bundle id)

Thanks everybody. Very kind all your support.
I will use in this stage of the development what @Derk Jochems suggest: “use a sms service which sends an control/activation code”.
I hope I could find a way to avoid this process.
I will appreciate if any of you find something in the future to let me know about it.
Thanks again