iTunes查找API在我的APP中返回旧数据 [英] iTunes lookup API return old data in my APP

查看:161
本文介绍了iTunes查找API在我的APP中返回旧数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的APP通过比较iTunes查找API返回的本地版本和远程版本来检查更新。但是在新版本发布后,API仍会返回旧版本。




My APP check update by comparing local version and remote version returned by iTunes lookup API. But the API still return old version after new version has released.

https://itunes.apple.com/us/lookup?bundleId=com.xxx.xxxx

This API return new version(4.9) if I request through browser, but return old version(4.8.1) in APP.

Anybody help? Thanks.

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

解决方案

I was also facing same issue but in my case I was using http (e.g. http://itunes.apple.com/lookup?bundleId=com.xxx.xxxx) so not getting latest app version. Then I replaced http to https (https://itunes.apple.com/lookup?bundleId=com.xxx.xxxx) after that its working for me.

Update - Our team sent mail to apple developers and ask why https is working and http is not working and got reply from apple team. He told "In general, there is a 24 hours delay for updated app information to go from App Store Connect to the public."

For more information see their email reply-

这篇关于iTunes查找API在我的APP中返回旧数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆