【问题标题】:App version different response应用版本不同响应
【发布时间】:2017-03-16 08:39:45
【问题描述】:

在我的应用程序中,我检查 AppStore 上的版本并显示适当的更新消息。
问题是我在 Postman 和这样的应用程序中调用了相同的 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];
}

我在 Postman 上收到 2 个不同的回复:

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

在应用上

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

有什么办法吗?

【问题讨论】:

  • 对我来说也发生了这个问题。您需要至少等待一天,Apple 服务器才能同步您的新应用版本详细信息。

标签: ios objective-c


【解决方案1】:

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

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

NSURLSession *sesion = [NSURLSession sessionWithConfiguration:configuration];

source

【讨论】:

    猜你喜欢
    • 2023-04-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-29
    • 1970-01-01
    • 1970-01-01
    • 2011-02-14
    相关资源
    最近更新 更多