使用testflight获取应用版本安装

时间:2017-09-11 12:41:59

标签: ios objective-c iphone testflight

我可以轻松地在appstore中使用以下API获取我的应用版本: -

http://itunes.apple.com/lookup?bundleId=com.app.bundleid&country=in

此外,我可以使用以下代码检查应用是否从testflight或appstore安装: -

if ([[NSBundle mainBundle] pathForResource:@"embedded" ofType:@"mobileprovision"]) {
    // TestFlight
} else {
    // App Store (and Apple reviewers too)
}

我的问题是,如何通过testflight获取我的应用安装版本。 例如:我在1.0.1发布appstore版本,而我的testflight上传版本是1.0.10,我需要检查testflight上传的应用版本。

这是我从appstore检查版本的代码

-(void)checkIsAppUpdated
{
    NSString *urlString = @"http://itunes.apple.com/lookup?bundleId=com.app.bundleid&country=in";
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlString]];
    [request setHTTPMethod:@"GET"];

    NSError *error = nil;
    NSURLResponse *response = nil;
    NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
    if (!error)
    {

        //The response is in data
        //NSLog(@"Success: %@", stringReply);
        NSDictionary *dictResponse = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
        float appStoreTestflightVersion=[[[[dictResponse objectForKey:@"results"] firstObject] objectForKey:@"version"] floatValue];

        NSLog(@"app stroe version=%f",appStoreTestflightVersion);

        NSString *strLocalVersion=[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
        float localAppVersion=[strLocalVersion floatValue];
        if (localAppVersion!=appStoreTestflightVersion)
        {

            //delete database here and then create it again


        }
    }

}

0 个答案:

没有答案