Solution for obtaining the unique identifier of a device on ios, ios Solution

Source: Internet
Author: User

Solution for obtaining the unique identifier of a device on ios, ios Solution

In iOS 7, Apple once again ruthlessly blocks mac addresses. Now, it cannot obtain the physical addresses of iOS 7 devices. How can we identify the uniqueness of a device during development? The method provided by apple is to store some logo information through the keychain, and then let the application identify the uniqueness of the device through the saved logo information.

Apple has written a simple tool class for operating the keychain: keystore:

 

 

 

Configure keychain sharing:

Here we can see the file ending with xxxxx. entitlements in the project. <? Xml version = "1.0" encoding = "UTF-8"?>

<! DOCTYPE plist PUBLIC "-// Apple // dtd plist 1.0 // EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

<Plist version = "1.0">

<String> $ (AppIdentifierPrefix) h. HelloWorld </string>

</Plist>

$ {AppldentifierPrefix} is the prefix of the developer account. It is provided by apple, https://developer.apple.com/membercenter/index.action. you can use your own account.

Access: key chain:

Java code  
  1. -(Void) setKeyChainValue
  2. {
  3. KeychainItemWrapper * keyChainItem = [[KeychainItemWrapper alloc] initWithIdentifier: @ "TestUUID" accessGroup: @ "XXXXXX. h. HelloWorld"];
  4. NSString * strUUID = [keyChainItem objectForKey :( id) kSecValueData];
  5. If (strUUID = nil | [strUUID isuid tostring: @ ""])
  6. {
  7. [KeyChainItem setObject: [self gen_uuid] forKey :( id) kSecValueData];
  8. }
  9. [KeyChainItem release];
  10. }
  11. -(NSString *) gen_uuid
  12. {
  13. CFUUIDRef uuid_ref = CFUUIDCreate (nil );
  14. CFStringRef uuid_string_ref = CFUUIDCreateString (nil, uuid_ref );
  15. CFRelease (uuid_ref );
  16. NSString * uuid = [NSString stringWithString: uuid_string_ref];
  17. CFRelease (uuid_string_ref );
  18. Return uuid;
  19. }

When an application runs on a device for the first time, our application saves a uuid to identify the device. When the device deletes the program, the uuid still exists in the device.

 


Help: What is unique in ios to identify a program?

I don't know where to use it
At the file level, each application exists in the form of a sandbox Directory, which is a randomly generated folder name similar to the following
D103006C-6807-4A40-AA9A-8564C7CEBB09
In an application, Bundle identifier is used to identify the unique program and match the app id of Provisioning profiles.
 
How can I determine whether an app is installed on an ios device?

The main idea is to use the XCode info of application B to be recognized. if Xcode 4.2 is used in plist, 1. in info. add a URL Schemes: XXX in plist. The details are as follows: 1.1 open info. plist: add an Item under the Information Property List: URL types 1.2 and add Item 0 under URL Types, this is a Dictionary 1.3. Add an Array 1.4 of the URL Schemes type under Item0 and add a URL identifier under the URL Schemes. The String value can be added to Item0 without filling in it, the String value is XXX. I started to see Adding URL Schemes on the Internet. I thought it would be an item directly added to the Information Property List. The key is URL Schemes and the value is XXX. Later I found that it does not work. Only the specified type can be added, and the related type is automatically displayed. The correct method is the above process. For Xcode 4.6, follow the steps below to add: solution: From 91SDK3. 2.5 The access party needs to set a URL Scheme. The setting method is as follows: select the Target in the project, select the Info tab, find the URL Types below, expand, and click the plus sign, create a new URL Scheme. After clicking, enter your software Identifier in the Identifier Field, and enter the URL Schemes field in the format of 91-xxxxx, where xxxx is your software Identifier. The Role field can be set to None, and the Icon field can be left empty. Example: 2. then, in application A of the active device, use this method to determine whether the app B [[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString: @ "XXX: // "]; If YES is returned, the application has been installed on the mobile phone, and vice versa. the Code is as follows:-(BOOL) APCheckIfAppInstalled2 :( NSString *) urlSchemes {if ([[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString: urlSchemes]) {NSLog (@ "installed"); return YES;} else {return NO;} can be determined by calling APCheckIfAppInstalled2: XXX Whether application B is installed. This method takes effect for jailbroken iOS devices or devices that have not been jailbroken. You can also view the com. apple. mobile. installation. the plist system file method can be determined by bundle identifier, but only the jailbreaking machine can be identified, because the jailbreaking machine can access this file, in a non-jailbreaking machine, because applications are not allowed to access directories outside the sandbox environment, they cannot read the file or even judge whether the file exists. The Code is as follows:-(BOOL) APCheckIfAppInstalled :( NSString *) bundleIdentifier {static NSString * const cacheFileName = @ "com. apple. mobile. ins ...... the remaining full text>

Related Article

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.