gpt4 book ai didi

ios - 应用版本不同响应

转载 作者:行者123 更新时间:2023-12-01 19:55:39 24 4
gpt4 key购买 nike

在我的应用程序中,我检查 AppStore 上的版本并显示正确的更新消息。
问题是相同的 URL http://itunes.apple.com/lookup?bundleId=my_app_bundle我调用 postman ,也调用这样的应用程序:

- (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];
}

我在 Postman 上收到 2 个不同的回复:
"currentVersionReleaseDate": "2017-03-15T23:14:08Z"
"version": "2.0.1"

并在应用程序上
currentVersionReleaseDate = "2017-03-13T07:37:19Z"
version = "2.0.0"

有什么解决办法吗?

最佳答案

好的,所以主要原因是数据被缓存了所以我更改了NSURLSession :

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

NSURLSession *sesion = [NSURLSession sessionWithConfiguration:configuration];

source

关于ios - 应用版本不同响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42828997/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com