My update is APP validation by comparing the local version and the remote version returned by the iTunes search API. But the API is still returning the old version after the release of the new version.
https://itunes.apple.com/us/lookup?bundleId=com.xxx.xxxx
This API returns a new version (4.9) if I request through a browser, but return the old version (4.8.1) to APP.
Anyone help? Thanks.
- (void)updateAppInfo
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSString *iTunesServiceURL = [NSString stringWithFormat:@"https://itunes.apple.com/us/lookup"];
iTunesServiceURL = [iTunesServiceURL stringByAppendingFormat:@"?bundleId=%@", [[NSBundle mainBundle] bundleIdentifier]];
NSLog(@"iRate is checking %@ to retrieve the App Store details...", iTunesServiceURL);
NSError *error = nil;
NSURLResponse *response = nil;
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:iTunesServiceURL] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60];
NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
NSInteger statusCode = ((NSHTTPURLResponse *)response).statusCode;
if (data && statusCode == 200)
{
error = nil;
id json = nil;
if ([NSJSONSerialization class])
{
json = [[NSJSONSerialization JSONObjectWithData:data options:(NSJSONReadingOptions)0 error:&error][@"results"] lastObject];
}
else
{
json = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
}
if (!error)
{
self.appStoreId = [self valueForKey:@"trackId" inJSON:json];
self.latestVersion = [self valueForKey:@"version" inJSON:json];
self.releaseNote = [self valueForKey:@"releaseNotes" inJSON:json];
}
}
});
}
source
share