Created
December 21, 2012 02:46
-
-
Save rjyo/4350338 to your computer and use it in GitHub Desktop.
Check app store update with SVHTTPClient.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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