废话不多说 直接上代码,喜欢的朋友帮忙点个赞
#pragma mark -- 检测版本 ---
//检测版本更新
-(void)onCheckVesion{
NSDictionary *infoDic = [[NSBundle mainBundle] infoDictionary];
//CFShow((__bridge CFTypeRef)(infoDic));
NSString *currentVersion = [infoDic objectForKey:@"CFBundleVersion"];
NSLog(@"当前版本的版本号----%@",currentVersion);
//如果是第一个版本,则直接返回
if ([currentVersion isEqualToString:@"1"]) {
DXAlertView *alert = [[DXAlertView alloc]initWithTitle:@"温馨提示" contentText:@"已是最新版本" leftButtonTitle:@"知道了" rightButtonTitle:@"取消"];
[alert show];
return;
}
NSString *URL = @"http://itunes.apple.com/lookup?id=1035222784";//在商店里面的appid
[LORequestManger POST:URL params:nil success:^(id response) {
NSDictionary *dic = response;
NSArray *infoArray = [dic objectForKey:@"results"];
if ([infoArray count]) {
NSDictionary *releaseInfo = [infoArray objectAtIndex:0];
NSString *lastVersion = [releaseInfo objectForKey:@"version"];
NSLog(@"appstore上面的版本号是-----%@",lastVersion);
NSString *trackViewURL = [releaseInfo objectForKey:@"trackVireUrl"];
NSLog(@"----trackviewURL === %@",trackViewURL);
if (![lastVersion isEqualToString:currentVersion]) {
//trackViewURL = [releaseInfo objectForKey:@"trackVireUrl"];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"任务管理" message:@"有新的版本更新,是否前往更新?" delegate:self cancelButtonTitle:@"关闭" otherButtonTitles:@"更新", nil];
alert.tag = 10000;
[alert show];
}
else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"任务管理" message:@"此版本为最新版本" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
alert.tag = 10001;
[alert show];
}
}
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"%@",error);
}];
}
//更新按钮的点击事件
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (alertView.tag==10000) {
if (buttonIndex==1) {
NSURL *url = [NSURL URLWithString:@"https://itunes.apple.com"];
[[UIApplication sharedApplication]openURL:url];
}
}
}
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。