"IOS" traverse all content of info && save device unique UUID

Source: Internet
Author: User

/** gets the device's imie*/std::string Deviceinfo::getimie () {#if (Cc_target_platform = = Cc_platform_ios) Nsstring*bunider = nil;    nsbundle* mainbundle = [NSBundle mainbundle];    nsdictionary* infodictionary = [Mainbundle infodictionary];    ID key;    nsarray* keys = [Infodictionary AllKeys];    NSLog (@ "Display all keys and values in info.plist\n");        For (key in keys) {NSString * keycfbundleversion = (nsstring*) key; if ([Keycfbundleversion isequaltostring:@ "Cfbundleidentifier"]) {NSLog (@ "Bundle identifier =%@", Keycfbu                        Ndleversion);            ID Version = [infodictionary Objectforkey:key];            Bunider = (nsstring*) version;        NSLog (@ "Bunider:%@", Bunider);    }//NSLog (@ "key=%@, value=%@\n", Key,[infodictionary Objectforkey:key]); } nsstring *uuid = nil;//need to use the Open source class sskeychain//sskeychains A simple encapsulation of the Apple Security Framework API,//support for passwords stored in keychain, access to accounts, including read, delete, and settings.    Sskeychain's author is Samsoffes, author of the famous Sstoolkit. Project GroundAddress: Https://github.com/samsoffes/sskeychain//Add Sskeychain//In the project to add the Security.framework framework.        Add SSKeychain.h and SSKEYCHAIN.M to the project folder.    NSString *retrieveuuid = [Sskeychain passwordforservice:bunider account:@ "user"];        if ([Retrieveuuid length] >0) {uuid = Retrieveuuid;        NSLog (@ "UUID =%@", uuid);    return [UUID utf8string]; } cfstringref ref = Cfuuidcreatestring (Kcfallocatordefault, Cfuuidcreate (Kcfal    Locatordefault));    UUID = (NSString *) ref;    Const char* DestDir = [uuid utf8string];    Cfrelease (ref);   Cclog ("uuid =%s", destDir);    string sime = DestDir;    Sime = Sime.substr (0,6);    Log ("Sime =%s", sime.c_str ());    UUID = [NSString stringwithformat:@ "%s", Sime.c_str ()];        [Sskeychain setpassword:uuid forservice:bunider account:@ "user"]; return sime; #elif (cc_target_platform==cc_platform_android) jnimethodinfo minfo;//define JNI function information structure//    The Getstaticmethodinfo function returns a bool value indicating whether this function is foundBOOL Ishave = Jnihelper::getstaticmethodinfo (Minfo, "Com/nx/deviceinfo", "Getimie", "() ljava/lang/string;"); if (ishave) {jstring jstr;jstr = (jstring) minfo.env->callstaticobjectmethod (Minfo.classid, Minfo.methodID); string Imie = jnihelper::jstring2string (JSTR); Cclog ("--------------------------------------->imie:%s", Imie.c_str ()); return Imie;} return "Androidleon"; #endif///////////////////////////////////////debugauto strings=fileutils::getinstance ()-    >getvaluemapfromfile ("Debug_text.xml"); std::string debug_user_name = strings["user_name"].asstring (); if (Debug_user_name.size () >0) {CCLOG ("==use debug   username== "); return debug_user_name;} return "12124124123123124wbytext";}

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.