I have a version checker inside my app and I have the current version number stored in a plist on the server. For some reason it keeps returning the old value when I have confirmed that it is 1.21 when it keeps saying 1.2. I believe it's some sort of caching as my browsers do the same thing.
How do I prevent this from happening? I set the cachePolicy to NSURLRequestReloadIgnoringCacheData
, but it's still returning 1.2 when it's 1.21
NSURL *url = [NSURL URLWithString:@"https://somewebsite.com/iosapp/CurrentVersion.plist"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
request.cachePolicy = NSURLRequestReloadIgnoringCacheData;
[request setHTTPMethod:@"GET"];
[AFPropertyListRequestOperation addAcceptableContentTypes:[NSSet setWithObject:@"text/xml"]];
AFPropertyListRequestOperation *operation = [AFPropertyListRequestOperation propertyListRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id propertyList) {
NSString *currentVersion = [[[NSArray alloc] initWithArray:propertyList] objectAtIndex:0];
NSLog(@"Current Version %@", currentVersion);
NSString *deviceVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey: @"CFBundleShortVersionString"];
if (![currentVersion isEqualToString:deviceVersion]) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Update Available" message:[NSString stringWithFormat:@"App %@ is available. Please update.", currentVersion] delegate:self cancelButtonTitle:@"Later" otherButtonTitles:@"Update", nil];
[alert show];
}
[self finalCheck];
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id propertyList) {
[self finalCheck];
}];