1

In my app I check the version on AppStore an display a proper message for update.
The problem is that the same URL http://itunes.apple.com/lookup?bundleId=my_app_bundle i call in Postman and also in app like this:

- (void)checkForNewVersion
{
    appIsLastVersion = YES;

    NSString *bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];
    NSString *currentAppVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];

    NSString *appInfoUrl = [NSString stringWithFormat:@"http://itunes.apple.com/lookup?bundleId=%@", bundleIdentifier];

    NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
    [request setURL:[NSURL URLWithString:appInfoUrl]];
    [request setHTTPMethod:@"GET"];

    NSURLSession *sesion = [NSURLSession sharedSession];
   NSURLSessionDataTask *task =  [sesion dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {

        NSString *output = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];

        NSError *e = nil;
        NSData *jsonData = [output dataUsingEncoding:NSUTF8StringEncoding];
        NSDictionary *jsonDict = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&e];

        NSArray *results = [jsonDict objectForKey:@"results"];
        if (results.count > 0) {
            NSString *version = [[[jsonDict objectForKey:@"results"] objectAtIndex:0] objectForKey:@"version"];
            appIsLastVersion = [version isEqualToString:currentAppVersion];

            [self.tableView reloadData];
        }
    }];

    [task resume];
}

i receive 2 different response on Postman:

"currentVersionReleaseDate": "2017-03-15T23:14:08Z"
"version": "2.0.1" 

and on app

currentVersionReleaseDate = "2017-03-13T07:37:19Z"
version = "2.0.0"

Any solution ?

Constantin Saulenco
  • 2,353
  • 1
  • 22
  • 44
  • For me also this issue is happen. You need to wait at least one day for apple server to sync your new app version details. – Antony Raphel Mar 16 '17 at 09:15

1 Answers1

2

Ok, so the main reason is that the data was cached so i changed the NSURLSession:

NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
configuration.requestCachePolicy = NSURLRequestReloadIgnoringLocalCacheData;

NSURLSession *sesion = [NSURLSession sessionWithConfiguration:configuration];

source

Community
  • 1
  • 1
Constantin Saulenco
  • 2,353
  • 1
  • 22
  • 44