IOS Development gets a unique identity

Source: Internet
Author: User

Tag: style io ar os SP for data on problem

In the Traffic wizard when there is such a demand, the account by default needs to take the phone's IMSI information. This has the advantage that even if the user deletes our app and downloads it again, they will be logged in the same status as the next entry and get the original record. This is not only for the development company personnel can be counted whether he is a new user, and for the user can not worry about before the record is deleted. (--Our software is not required to register, as long as the user login by default to IMSI as a unique sign to register).

But in iOS development, it was found that different systems such as IOS5, iOS6.0, and iOS7, Apple's attitude toward it were completely different. It is estimated that Apple is a security concern, and it is completely impossible for you to take these private messages after 6.0. All the functions have been blocked. While it's not a good idea to look at it as a development, on the other hand, as a Steve Jobs fan, I can totally understand Apple's move. (Think about it, if you're a user, and every piece of software you've loaded in your phone can get your private information in any case, such as: Imsi,imei, mobile phone number, or your geo-location information.) What a horrible thing it was. Jobs didn't want to open iOS to the world to keep others from polluting his stores, polluting users and polluting the system.

For a variety of reasons, I still have a relative admiration for Steve Jobs.

Since we can't solve the problem directly, let's try to solve it: Here are a few.

1, using Nsuserdefaults access

-(nsstring*) Uniqueappinstanceidentifier

{

nsuserdefaults* userdefaults = [Nsuserdefaults standarduserdefaults];

static nsstring* Uuid_key = @ "Mpuuid";

nsstring* app_uuid = [Userdefaults Stringforkey:uuid_key];

if (App_uuid = = nil) {

Cfuuidref uuidref = cfuuidcreate (Kcfallocatordefault);

Cfstringref uuidstring = cfuuidcreatestring (Kcfallocatordefault, uuidref);

App_uuid = [NSString stringwithstring: (__bridge nsstring*) uuidstring];

[Userdefaults Setobject:app_uuid Forkey:uuid_key];

[Userdefaults Synchronize];

Cfrelease (uuidstring);

Cfrelease (UUIDREF);

}

return app_uuid;

}

This method ensures that the user does not remove the software in the case of obtaining the same data. Because the nsuserdefaults data is stored in the sandbox, it will be emptied as the software is deleted.

2. Use [[Uidevice Currentdevice] Identifierforvendor]. Uuidstring

This method was introduced after the official 6.0 system, the designation of a unique symbol, different software, different machines, the time of the operation is not the same, that is, to meet the identity of uniqueness, I used this method for a period of time to obtain data. But there's a tangled question:

A, most of the genuine mobile phone in the software uninstall, and then reinstall the case will remain and originally saved the same value.

b, I always thought this method is ok at the same time, one day, suddenly a test said: "I uninstalled the software, but the data are empty ...." What's going on here. "And later found you right. Some jailbreak or beauty version of the mobile phone will be reproduced after the acquisition of data. --my goodness ....

The most convenient solution, then be rejected, or some lost!

Also based on these now there is no space to rethink this question .... Device Unique identifier, and this identifier can be consistent with the original after the software unloading load .....

3. Keychian Scheme

This program I have always known between the development, but also to the new medium-size, but I do not want to do it completely. The reason is simple, what does a tool software mean?   For useless development I have always been very disgusted, very annoying.   People always think of the perfect thing, but do not know what the perfect is what they want, always say later will be useful, always think that this will make oneself become a thinking comprehensive person. But in my opinion it is not so, most of them think so, because they think too little, the future is too confused, and conservative to do not want to make a mistake .... Remember when you first graduated from the sentence: "To do a omnipotent thing is absolutely impossible ...." Do not encode all the time for future reasons. "So my answer is simple: you need to know exactly what you want, and I'll give you a clear answer."

Words return to positive turn:

Keychian is stored outside the sandbox data, equivalent to dictionary, all applications can be obtained and saved, so when a software uninstall completely does not affect the data inside, so when the software reinstall, it is natural to get the original data inside.

Here I use some of the code that someone else has encapsulated sfhfkeychainutils(can be downloaded on the Internet):

Save data

BOOL s = [sfhfkeychainutils storeusername:name andpassword:pswd forservicename:server updateexisting:no Error:nil] ;

Get password

NSString * PSW = [sfhfkeychainutils getpasswordforusername:name andservicename:server Error:nil];

Well, that's the end of the program.

IOS Development gets a unique identity

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.