Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iTunes lookup API return old data in my APP

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];
        }
    }
    });
}
like image 485
Jack Avatar asked Apr 05 '17 09:04

Jack


3 Answers

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-enter image description here

like image 59
Dipak Avatar answered Oct 21 '22 20:10

Dipak


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.
like image 2
Vea Avatar answered Oct 21 '22 21:10

Vea


I was facing the same issue. It has two steps to resolve this issue.

I was using http://itunes.apple.com/lookup?bundleId="YOUR BUNDLE ID" not the https.

Step #1: Please ensure that you are using https not the http because it will not give you the updated version number. First i uploaded my app with version 1.8.0 then version 1.9.0 then version 1.9.1. When i used http it was always showing me 1.8.0 even the app on app store had the version 1.9.1. So, just use https for future.

Step #2: After uploading the latest version please wait for 24 hours in order to get the latest version on https://itunes.apple.com/lookup?bundleId="YOUR BUNDLE ID". I was getting version 1.9.0 even though the app was live with version 1.9.1 within 24 hours. I waited for 24 hours and then it started giving me the correct version and then i was able to force update my app by version checking.

like image 1
Syed Faizan Ahmed Avatar answered Oct 21 '22 21:10

Syed Faizan Ahmed