본문 바로가기

iOS

앱스토어 버전 가져오기

앱스토어 버전가져오기


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

    NSString *bundleIdentifier = [bundleInfo valueForKey:@"CFBundleIdentifier"];

    NSURL *lookupURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://itunes.apple.com/lookup?bundleId=%@", bundleIdentifier]];

    NSData *lookupResults = [NSData dataWithContentsOfURL:lookupURL];

    NSDictionary *jsonResults = [NSJSONSerialization JSONObjectWithData:lookupResults options:0 error:nil];

    

    NSUInteger resultCount = [[jsonResults objectForKey:@"resultCount"] integerValue];

    if (resultCount){

        NSDictionary *appDetails = [[jsonResults objectForKey:@"results"] firstObject];

        NSString *latestVersion = [appDetails objectForKey:@"version"];

        NSString *currentVersion = [bundleInfo objectForKey:@"CFBundleShortVersionString"];

    }


더궁금하시면 댓글 남겨주세요 

'iOS' 카테고리의 다른 글