Skip to content

Instantly share code, notes, and snippets.

@rjyo
Created December 21, 2012 02:46
Show Gist options
  • Save rjyo/4350338 to your computer and use it in GitHub Desktop.
Save rjyo/4350338 to your computer and use it in GitHub Desktop.
Check app store update with SVHTTPClient.
SVHTTPClient *client = [SVHTTPClient sharedClientWithIdentifier:@"APPSTORE"];
client.basePath = @"http://itunes.apple.com";
[client GET:[NSString stringWithFormat:@"/lookup?id=%d", APP_STORE_ID] parameters:nil completion:^(id response, NSHTTPURLResponse *urlResponse, NSError *error) {
NSDictionary *result = [response objectFromJSONDataWithParseOptions:JKParseOptionStrict];
if (result) {
NSString *latestVersion = [[result valueForKeyPath:@"results.version"] objectAtIndex:0];
NSString *appStoreURL = [[result valueForKeyPath:@"results.trackViewUrl"] objectAtIndex:0];
NSString *appName = [[result valueForKeyPath:@"results.trackName"] objectAtIndex:0];
NSString *applicationVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
if ([latestVersion compare:applicationVersion options:NSNumericSearch] == NSOrderedDescending) {
// Show prompts
} else {
DLog(@"No need to update");
}
}
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment