我无法在iOS App Store上查看应用程序新版本

时间:2018-06-12 10:15:07

标签: ios objective-c

我想检查已发布的iOS应用程序的最新版本,但代码无效。我得到结果计数0.这是代码,请检查并告诉我哪里出错?

NSDictionary* infoDictionary = [[NSBundle mainBundle] infoDictionary];
NSString* appID = infoDictionary[@"CFBundleIdentifier"];
NSURL* url = [NSURL URLWithString:[NSString stringWithFormat:@"http://itunes.apple.com/lookup?bundleId=%@", appID]];
NSData* data = [NSData dataWithContentsOfURL:url];
NSDictionary* lookup = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];

if ([lookup[@"resultCount"] integerValue] == 1){
    NSString* appStoreVersion = lookup[@"results"][0][@"version"];
    NSString* currentVersion = infoDictionary[@"CFBundleShortVersionString"];
    if (![appStoreVersion isEqualToString:currentVersion]){
        NSLog(@"Need to update [%@ != %@]", appStoreVersion, currentVersion);
        return YES;
    }
}

0 个答案:

没有答案