Get information such as device Udid, IMEI, ICCID, serial number, MAC address, etc.

Source: Internet
Author: User

Before iOS7, it is convenient to use [[Uidevice Currentdevice] uniqueidentifier] to obtain the udid of the device, but this method is no longer applicable after iOS7.

You can use [[uidevicecurrentdevice]valueforkey:@] uniqueidentifier to get a value, but this value has become the FFFFFF+IDFV value in IOS7, and obviously, This value does not uniquely identify the device.

Another talk about the IMEI, this value seems to be missing in the 5.0 SDK, the private library message.framework MFNetworkController.h removed this method.

I think iOS7 and above system can not get these values, but look at others Cydia, not to get good? Refer to the source code of Cydia:

mobilecydia.mm

You can see that it uses the Libmobilegestalt.dylib dynamic library, and here's how to do that.

1. Import Libmobilegestalt.dylib Library

2. Declaration of Accession

[OBJC]View Plaincopyprint?
    1. Objc_externcfstringref mgcopyanswer (cfstringref key) Weak_import_attribute;

3, use the following methods to obtain

[OBJC]View Plaincopyprint?
    1. Cfstringref UDID = Mgcopyanswer (Cfstr ("Uniquedeviceid"));
    2. Cfstringref IMEI =mgcopyanswer (cfstr ("internationalmobileequipmentidentity"));
    3. Cfstringrefserialnumber = Mgcopyanswer (Cfstr ("serialnumber"));
[OBJC]View Plaincopyprint?
    1. Cfarrayref Iccidarray =mgcopyanswer (cfstr ("Carrierbundleinfoarray"));
    2. Cfdictionaryref icciddic =cfarraygetvalueatindex (iccidarray, 0);
    3. Cfstringref ICCID =cfdictionarygetvalue (Icciddic, Cfstr ("integratedcircuitcardidentity"));
[OBJC]View Plaincopyprint?
    1. cfstringrefwifiaddress = Mgcopyanswer (Cfstr ("wifiaddress"));
    2. cfstringrefbluetoothaddress = Mgcopyanswer (Cfstr ("bluetoothaddress"));
    3. Cfstringrefcpuarchitecture = Mgcopyanswer (Cfstr ("cpuarchitecture"));
    4. Cfstringrefproducttype = Mgcopyanswer (Cfstr ("ProductType"));
    5. Cftyperefairplanemode = Mgcopyanswer (Cfstr ("Airplanemode"));
    6. if (Airplanemode ==kcfbooleantrue) {...}

4, after testing found these methods in the iOS7 below without jailbreak can be taken, in iOS7 need to jailbreak and create Xxx.entitlements file, add the following permissions

5. Add the file you just created in buildsettings code signingentitlements xxx.entitlements

6. Compile and run

7. Attach Demo Project

http://download.csdn.net/detail/ookcode/8247495

8. My environment

Xcode 6.1

IOS 8.1 SDK

OS X 10.9.5

Get information such as device Udid, IMEI, ICCID, serial number, MAC address, etc.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.