# How to get IMEI and phone number

**URL:** <https://forum.xojo.com/t/how-to-get-imei-and-phone-number/32267>\
**Category:** Targets\
**Created:** [July 2, 2016, 1:10pm UTC](https://forum.xojo.com/t/how-to-get-imei-and-phone-number/32267 "2016-07-02T13:10:36Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mariano\_Poli](https://forum.xojo.com/user_avatar/forum.xojo.com/mariano_poli/32/340_2.png) [@Mariano\_Poli](https://forum.xojo.com/u/Mariano_Poli)\
**Post date:** [July 2, 2016, 1:10pm UTC](https://forum.xojo.com/t/how-to-get-imei-and-phone-number/32267/1 "2016-07-02T13:10:36Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Tomas\_J](https://forum.xojo.com/user_avatar/forum.xojo.com/tomas_j/32/311_2.png) [@Tomas\_J](https://forum.xojo.com/u/Tomas_J)\
**Post date:** [July 2, 2016, 3:25pm UTC](https://forum.xojo.com/t/how-to-get-imei-and-phone-number/32267/2 "2016-07-02T15:25:33Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Tim\_Parnell](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_parnell/32/161_2.png) [@Tim\_Parnell](https://forum.xojo.com/u/Tim_Parnell)\
**Post date:** [July 2, 2016, 3:45pm UTC](https://forum.xojo.com/t/how-to-get-imei-and-phone-number/32267/3 "2016-07-02T15:45:17Z")

</div>

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](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)

---

<div class="post-metadata">

**Author:** ![Mariano\_Poli](https://forum.xojo.com/user_avatar/forum.xojo.com/mariano_poli/32/340_2.png) [@Mariano\_Poli](https://forum.xojo.com/u/Mariano_Poli)\
**Post date:** [July 2, 2016, 4:46pm UTC](https://forum.xojo.com/t/how-to-get-imei-and-phone-number/32267/4 "2016-07-02T16:46:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Michel\_Bujardet](https://forum.xojo.com/user_avatar/forum.xojo.com/michel_bujardet/32/252_2.png) [@Michel\_Bujardet](https://forum.xojo.com/u/Michel_Bujardet)\
**Post date:** [July 2, 2016, 5:12pm UTC](https://forum.xojo.com/t/how-to-get-imei-and-phone-number/32267/5 "2016-07-02T17:12:09Z")

</div>

[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](https://www.marekbell.com/udid-and-uuid-alternative-for-ios/). 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.

---

<div class="post-metadata">

**Author:** ![Tim\_Parnell](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_parnell/32/161_2.png) [@Tim\_Parnell](https://forum.xojo.com/u/Tim_Parnell)\
**Post date:** [July 2, 2016, 5:15pm UTC](https://forum.xojo.com/t/how-to-get-imei-and-phone-number/32267/6 "2016-07-02T17:15:00Z")

</div>

You can’t get the MAC anymore.  
[http://stackoverflow.com/a/20902339](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.

---

<div class="post-metadata">

**Author:** ![Mariano\_Poli](https://forum.xojo.com/user_avatar/forum.xojo.com/mariano_poli/32/340_2.png) [@Mariano\_Poli](https://forum.xojo.com/u/Mariano_Poli)\
**Post date:** [July 2, 2016, 6:56pm UTC](https://forum.xojo.com/t/how-to-get-imei-and-phone-number/32267/7 "2016-07-02T18:56:22Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Tim\_Parnell](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_parnell/32/161_2.png) [@Tim\_Parnell](https://forum.xojo.com/u/Tim_Parnell)\
**Post date:** [July 2, 2016, 7:07pm UTC](https://forum.xojo.com/t/how-to-get-imei-and-phone-number/32267/8 "2016-07-02T19:07:14Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![DerkJ](https://forum.xojo.com/letter_avatar_proxy/v4/letter/d/e495f1/32.png) [@DerkJ](https://forum.xojo.com/u/DerkJ)\
**Post date:** [July 2, 2016, 7:27pm UTC](https://forum.xojo.com/t/how-to-get-imei-and-phone-number/32267/9 "2016-07-02T19:27:35Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Michel\_Bujardet](https://forum.xojo.com/user_avatar/forum.xojo.com/michel_bujardet/32/252_2.png) [@Michel\_Bujardet](https://forum.xojo.com/u/Michel_Bujardet)\
**Post date:** [July 2, 2016, 7:54pm UTC](https://forum.xojo.com/t/how-to-get-imei-and-phone-number/32267/10 "2016-07-02T19:54:00Z")

</div>

[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.

---

<div class="post-metadata">

**Author:** ![Greg\_O\_Lone](https://forum.xojo.com/user_avatar/forum.xojo.com/greg_o_lone/32/49_2.png) [@Greg\_O\_Lone](https://forum.xojo.com/u/Greg_O_Lone)\
**Post date:** [July 2, 2016, 8:55pm UTC](https://forum.xojo.com/t/how-to-get-imei-and-phone-number/32267/11 "2016-07-02T20:55:19Z")

</div>

> [@275292:@Michel Bujardet](#):
>
> 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.

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.

---

<div class="post-metadata">

**Author:** ![Michel\_Bujardet](https://forum.xojo.com/user_avatar/forum.xojo.com/michel_bujardet/32/252_2.png) [@Michel\_Bujardet](https://forum.xojo.com/u/Michel_Bujardet)\
**Post date:** [July 2, 2016, 9:06pm UTC](https://forum.xojo.com/t/how-to-get-imei-and-phone-number/32267/12 "2016-07-02T21:06:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Norman\_P](https://forum.xojo.com/letter_avatar_proxy/v4/letter/n/858c86/32.png) [@Norman\_P](https://forum.xojo.com/u/Norman_P)\
**Post date:** [July 2, 2016, 9:18pm UTC](https://forum.xojo.com/t/how-to-get-imei-and-phone-number/32267/14 "2016-07-02T21:18:05Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![Mariano\_Poli](https://forum.xojo.com/user_avatar/forum.xojo.com/mariano_poli/32/340_2.png) [@Mariano\_Poli](https://forum.xojo.com/u/Mariano_Poli)\
**Post date:** [July 4, 2016, 6:53am UTC](https://forum.xojo.com/t/how-to-get-imei-and-phone-number/32267/15 "2016-07-04T06:53:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://forum.xojo.com/uploads/default/original/1X/455b4dcc0e61630e9f81940004ddffa49c432a46.png) [@system](https://forum.xojo.com/u/system)\
**Post date:** [October 29, 2020, 6:22pm UTC](https://forum.xojo.com/t/how-to-get-imei-and-phone-number/32267/16 "2020-10-29T18:22:57Z")

</div>


