获取appStore市场应用实时版本号 iOS

2020-09-16  本文已影响0人  留一份空白

获取appstore应用版本号

    WS(ws);

    ddownStr = @"http://itunes.apple.com/lookup?id=********";

    [self defaultRequestwithURL:ddownStr withParameters:nil withMethod:kPOST withBlock:^(NSDictionary *dict, NSError *error) {

        NSLog(@"%@",dict);

        NSLog(@"🧊🧊%@",[dict objectForKey:@"results"]);

        NSDictionary *infoDic = [[NSBundle mainBundle] infoDictionary];

        NSString *currentVersion = infoDic[@"CFBundleShortVersionString"];

        if ([dict objectForKey:@"results"]) {

            NSArray *tempArr = [dict objectForKey:@"results"];

            if (tempArr.count > 0) {

                NSDictionary *tempDic = [tempArr objectAtIndex:0];

                if ([tempDic objectForKey:@"version"]) {

                    NSString *verstring = [NSString stringWithFormat:@"%@",[tempDic objectForKey:@"version"]];

                    //当前版本号

                    NSInteger currentVerRR =

                    [[(NSMutableString *)currentVersion stringByReplacingOccurrencesOfString:@"." withString:@""] intValue];

                    //最新VV

                    NSInteger cNewVerRR =

                    [[(NSMutableString *)verstring stringByReplacingOccurrencesOfString:@"." withString:@""] intValue];

                    if (cNewVerRR > currentVerRR) {

                        [ws liz_showUpdateAlertWithOldVersion:currentVersion withNew:[NSString stringWithFormat:@"%@",verstring] withUrl:dJumpStr contentStr:content];

                    }

                }

            }

        }

    }];

上一篇 下一篇

猜你喜欢

热点阅读