我的APP通过比较iTunes查找API返回的本地版本和远程版本来检查更新.但新版本发布后,API仍会返回旧版本.
https://itunes.apple.com/us/lookup?bundleId=com.xxx.xxxx
如果我通过浏览器请求,此API返回新版本(4.9),但在APP中返回旧版本(4.8.1).
有人帮忙吗?谢谢.
- (void)updateAppInfo { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0),^{ //first check iTunes NSString *iTunesServiceURL = [NSString stringWithFormat:@"https://itunes.apple.com/us/lookup"]; iTunesServiceURL = [iTunesServiceURL stringByAppendingFormat:@"?bundleId=%@",[[NSBundle mainBundle] bundleIdentifier]]; NSLog(@"iRate is checking %@ to retrieve the App Store details...",iTunesServiceURL); NSError *error = nil; NSURLResponse *response = nil; NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:iTunesServiceURL] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60]; NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error]; NSInteger statusCode = ((NSHTTPURLResponse *)response).statusCode; if (data && statusCode == 200) { //in case error is garbage... error = nil; id json = nil; if ([NSJSONSerialization class]) { json = [[NSJSONSerialization JSONObjectWithData:data options:(NSJSONReadingOptions)0 error:&error][@"results"] lastObject]; } else { //convert to string json = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; } if (!error) { self.appStoreId = [self valueForKey:@"trackId" inJSON:json]; self.latestVersion = [self valueForKey:@"version" inJSON:json]; self.releaseNote = [self valueForKey:@"releaseNotes" inJSON:json]; } } }); }
解决方法
我也面临同样的问题,但在我的情况下,我使用http(例如
http://itunes.apple.com/lookup?bundleId=com.xxx.xxxx),所以没有获得最新的应用程序版本.然后我将http替换为https(
https://itunes.apple.com/lookup?bundleId=com.xxx.xxxx),之后它为我工作.
更新 – 我们的团队向苹果开发人员发送了邮件,并询问为什么https正在运行且http无效,并得到苹果团队的回复.他告诉“一般情况下,更新的应用信息会延迟24小时从App Store Connect发送给公众.”