ITunes Search API returns old data in my APP

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), ^{
    //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];
        }
    }
    });
}
+6
source share
2 answers

I have the same problem too. I spoke with another developer, and he came to the conclusion that this could be a CDN problem. (Content Delivery Network)

  • When I connect to our Wi-Fi, the answer is out of date.
  • 4G, .
+1

. URL-, . /us/ .

: API iTunes

0

Source: https://habr.com/ru/post/1016313/


All Articles