【IOS】 遍曆info 的所有內容 && 儲存裝置唯一UUID

來源:互聯網
上載者:User

標籤:des   android   class   blog   code   java   

/**擷取裝置的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 = %@",keyCFBundleVersion);                        id  version =   [infoDictionary objectForKey:key];            bunider = (NSString*)version;            NSLog(@"bunider : %@",bunider);        }       // NSLog(@"key=%@ , value=%@\n",key,[infoDictionary objectForKey:key]);    }     NSString *uuid = Nil;//    需要用到開源類SSKeychain//    SSKeyChains對蘋果安全架構API進行了簡單封裝,//    支援對儲存在鑰匙串中密碼、賬戶進行訪問,包括讀取、刪除和設定。//    SSKeyChain的作者是大名鼎鼎的SSToolkit的作者samsoffes。    //    項目地址:https://github.com/samsoffes/sskeychain    //    在工程中加入SSKeyChain    //    在工程中加入Security.framework架構。//    把SSKeychain.h和SSKeychain.m加到專案檔夾。        NSString *retrieveuuid = [SSKeychain passwordForService:bunider account:@"user"];    if ([retrieveuuid length] >0) {        uuid =  retrieveuuid;        NSLog(@"uuid = %@",uuid);        return [uuid UTF8String];    }     CFStringRef ref = CFUUIDCreateString(kCFAllocatorDefault,                                         CFUUIDCreate(kCFAllocatorDefault));    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;//定義Jni函數資訊結構體    //getStaticMethodInfo 次函數返回一個bool值表示是否找到此函數    bool 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";}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.