App版本响应不同(App version different response)

编程入门 行业动态 更新时间:2024-10-14 04:24:24
App版本响应不同(App version different response)

在我的应用程序中,我检查AppStore上的版本显示正确的更新消息。 问题是我在Postman和app中调用了相同的URL http://itunes.apple.com/lookup?bundleId=my_app_bundle ,如下所示:

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

我收到邮递员的2个不同回复:

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

并在应用程序上

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

有解决方案吗

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 ?

最满意答案

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

NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration]; configuration.requestCachePolicy = NSURLRequestReloadIgnoringLocalCacheData; NSURLSession *sesion = [NSURLSession sessionWithConfiguration:configuration];

资源

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

更多推荐

本文发布于:2023-07-07 21:29:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1068454.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:版本   App   response   version

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!