My APP check update by comparing local version and remote version returned by iTunes lookup API. But the API still return old version after new version has released.
https://itunes.apple.com/us/lookup?bundleId=com.xxx.xxxx
This API return new version(4.9) if I request through browser, but return old version(4.8.1) in APP.
Anybody help? Thanks.
- (void)updateAppInfo
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
//first check iTunes
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)
{
//in case error is garbage...
error = nil;
id json = nil;
if ([NSJSONSerialization class])
{
json = [[NSJSONSerialization JSONObjectWithData:data options:(NSJSONReadingOptions)0 error:&error][@"results"] lastObject];
}
else
{
//convert to string
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];
}
}
});
}
I was also facing same issue but in my case I was using http (e.g. http://itunes.apple.com/lookup?bundleId=com.xxx.xxxx) so not getting latest app version. Then I replaced http to https (https://itunes.apple.com/lookup?bundleId=com.xxx.xxxx) after that its working for me.
Update - Our team sent mail to apple developers and ask why https is working and http is not working and got reply from apple team. He told "In general, there is a 24 hours delay for updated app information to go from App Store Connect to the public."