zoukankan      html  css  js  c++  java
  • iOS获取当前app的名称和版本号及其他信息(持续维护)


    // 1. iOS 获取到的 APP 的信息
    //
    iOS获取当前app的名称和版本号 NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];//获取app版本信息 NSLog(@"%@",infoDictionary); //这里会得到很对关于app的相关信息 // 下面,我们开始取需要的字段: // 1.app名称 NSString *app_Name = [infoDictionary objectForKey:@"CFBundleDisplayName"]; NSLog(@"1.app名称: %@",app_Name); // 2.app版本 NSString *applocalversion = [infoDictionary objectForKey:@"CFBundleShortVersionString"]; NSLog(@"2.app版本: %@",applocalversion); // 3.app build版本 NSString *app_build = [infoDictionary objectForKey:@"CFBundleVersion"]; NSLog(@"3.app build版本: %@",app_build); // 4..app getAppBundleId版本获取当前App的包名信息 NSString *app_BundleId = [infoDictionary objectForKey:@"CFBundleIdentifier"]; NSLog(@"4.app 包名: %@",app_BundleId); // 5.app 当前App的发行地区 NSString *app_getAppBundleId = [infoDictionary objectForKey:@"CFBundleDevelopmentRegion"]; NSLog(@"5.app 发行地区: %@",app_getAppBundleId);

       //  2. iOS 获取到的手机信息
        
    // a1.手机别名: 用户定义的名称
        NSString *userPhoneName = [[UIDevice currentDevice] name];
        NSLog(@"a1.手机别名: %@", userPhoneName);
        // a2.手机名称
        NSString *deviceName = [[UIDevice currentDevice] systemName];
        NSLog(@"a2.手机名称: %@",deviceName );
        // a3.手机系统版本
        NSString *phoneVersion = [[UIDevice currentDevice] systemVersion];
        NSLog(@"a3.手机系统版本: %@", phoneVersion);
        // a4.手机型号
        NSString *phoneModel = [[UIDevice currentDevice] model];
        NSLog(@"a4.手机型号: %@",phoneModel);
        // a5.地方型号  (国际化区域名称)
        NSString *localPhoneModel = [[UIDevice currentDevice] localizedModel];
        NSLog(@"a5.国际化区域名称: %@",localPhoneModel);
      // a6.设备唯一标识符
       NSString *identifier = [[[UIDevice currentDevice] identifierForVendor] UUIDString];

        NSLog(@"设备唯一标识符:%@",identifier);

    有时候我们不能获取到准确的app版本号是因为app上架的地区有时差不能马上实时同步,比如在中国区11月25号上架了,但是美国比我们晚12个小时,美国当地时间还不到11月25号,他们还是25号所以海外地区会晚一点,所以为了能准确获取我们测试的中国地区可以这样做

    dispatch_async(dispatch_queue_create("check_version_queue", DISPATCH_QUEUE_CONCURRENT), ^{
            NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
            [request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://itunes.apple.com/cn/lookup?id=%@",appID]]];
            [request setHTTPMethod:@"POST"];
            NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
            NSDictionary *jsonData = [NSJSONSerialization JSONObjectWithData:returnData options:0 error:nil];
    
      for (NSDictionary *dic in jsonData) {
    //        NSLog(@"%@",jsonData);
            NSLog(@"%@",[jsonData objectForKey:@"citynm"]);
        }
    

     获取app在 App Store上的json信息url

    国外:https://itunes.apple.com/lookup?id=xxx

    国内:https://itunes.apple.com/cn/lookup?id=xxx

    在国内,建议使用国内地址,国外地址可能会出现版本信息不一致的问题

  • 相关阅读:
    jpeg 文档格式
    gif 文件格式
    firefox前世今生
    png 文档格式
    字符'\xe5\x8c\x97\xe4\xba\xac\xe6\x96\xb0\xe5\x8d\x8e\xe7\x94\xb5\xe8\x84\x91\xe5\xad\xa6\xe6\xa0\xa1' 转为汉字
    SQL server 报错:
    encode 与 decode
    Octave 作图 无响应
    qmake建工程
    urlparse (scheme、netloc、path等)
  • 原文地址:https://www.cnblogs.com/gaozhang12345/p/11419182.html
Copyright © 2011-2022 走看看