- (void)updateVersion
{
//appid 是上传IPA的ID APIToken 查看文档如何生成
NSString *idUrlString = @"http://api.fir.im/apps/latest/APPID?api_token=XXX";
NSURL *requestURL = [NSURL URLWithString:idUrlString];
NSURLRequest *request = [NSURLRequest requestWithURL:requestURL];
NSURLResponse *response = nil;
NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:nil];
NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
NSDictionary *infoDic = [[NSBundle mainBundle] infoDictionary];
NSString *currentVersion = [infoDic objectForKey:@"CFBundleShortVersionString"];
NSDictionary *version = [dic objectForKey:@"versionShort"];
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue currentQueue] completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
//在线版本与本地版本比较
if (version > currentVersion) {
//do something
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"版本有更新" message:[NSString stringWithFormat:@"检测到新版本(%@),是否更新?",version] delegate:self cancelButtonTitle:nil otherButtonTitles:@"更新",nil];
[alert show];
}else
{
}
}];
}
- (void)alertView:(UIAlertView*)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
//5实现跳转更新
if(buttonIndex==0)
{
//获取下载token 转码生成plist文件,完成下载跳转URL 直接openURL
NSString * urlString = @"https://download.fir.im/v2/app/install/APPID?download_token=XXX";
NSString *URLencodeString = CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)urlString, NULL, CFSTR(":/?#[]@!$ &'()*+,;=\"<>%{}|\\^~`"), CFStringConvertNSStringEncodingToEncoding(NSUTF8StringEncoding)));
NSString *installURL = [NSString stringWithFormat:@"itms-services://?action=download-manifest&url=%@", URLencodeString];
NSURL *openURL = [NSURL URLWithString:installURL];
[[UIApplication sharedApplication] openURL:openURL];
}
}
fir.im 上企业版IPA版本更新
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 整个上传过程比较顺利,如果在上传过程中有遇到问题的童鞋请移步goole: 1.用xcode打好包 2.打开term...