标签:
iOS版本更新:调接口
后台返回三种状态 1.强制更新 2.无需更新 3.用户选择是否更新
- (void)requestToCheckVersion
{
ELifeNetRequestData *req = [[ELifeNetRequestData alloc] init];
[req setString:MFAppVersionShort forKey:@"versionNo"];
[req setString:@"iphone" forKey:@"osName"];
[[ELifeNetAPIClient sharedClient] requestPostWithType:ELifeRequest_getVersion args: [req toDictionary]
success:^(id responseObject) {
int forceUpgrade = [[responseObject objectForKey:@"forceUpgrade"] intValue];
self.updateUrl = [responseObject objectForKey:@"upgradeUrl"];
if (forceUpgrade == 1) {
//强制更新
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:self.updateUrl]];
return ;
}else if (forceUpgrade == 2){
//无需更新
return;
}else if (forceUpgrade == 3){
//用户选择是否更新 alert
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"" message:@"有新版本,现在去更新吗?" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
alert.tag = 1012;
[alert show];
}
} failure:^(NSError *error) {
}];
}
标签:
原文地址:http://www.cnblogs.com/fantasy3588/p/4707453.html