问题
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];
}
}
});
}
回答1:
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."
For more information see their email reply-
回答2:
I'm also having the same issue now. I talked to another developer and he came into the conclusion that it could be a CDN issue. (Content delivery network)
- When I connect to our wifi, the response is outdated.
- When I connect to my 4G data, the response is updated.
回答3:
Not all apps are available in all countries. In your URL, looking for it in the US store. Remove /us/ and try.
For more details: iTunes search API won't show existing app info
来源:https://stackoverflow.com/questions/43226752/itunes-lookup-api-return-old-data-in-my-app