[iOS] 앱스토어 버전 체크하기
NSDictionary *bundleInfo = [[NSBundle mainBundle] infoDictionary]; // 번들 정보
NSString *bundleIdentifier = [bundleInfo valueForKey:@"<wbr />CFBundleIdentifier"]; // 번들 id
NSURL *lookupURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://<wbr />itunes.apple.com/lookup?<wbr />bundleId=%@", bundleIdentifier]]; // 앱스토어 url
NSData *lookupResults = [NSData dataWithContentsOfURL:<wbr />lookupURL]; // 검색 결과
NSDictionary *jsonResults = [NSJSONSerialization JSONObjectWithData:<wbr />lookupResults options:0 error:nil]; // json으로 결과 보내기
NSUInteger resultCount = [[jsonResults objectForKey:@"resultCount"] integerValue]; // 결과 갯수
if (resultCount) // 결과가 있다면
{
NSDictionary *appDetails = [[jsonResults objectForKey:@"results"] firstObject]; // 첫번 째 결과 가져오기
NSString *latestVersion = [appDetails objectForKey:@"version"];
NSString *currentVersion = [bundleInfo objectForKey:@"<wbr />CFBundleShortVersionString"];
NSLog(@"lastestVersion = %@",latestVersion); // 앱스토어 버전
NSLog(@"currentVersion = %@",currentVersion); // 현재 소스의 버전
}