==================获取新版本,去appStore下载===================
#define SHAREURL @"https://itunes.apple.com/cn/app/liang-pin-gou-wu/id1142121819?mt=8"
//获取本地版本
-(NSString*)getAPPVerson{
NSString* version = [[[NSBundlemainBundle]infoDictionary]objectForKey:@"CFBundleShortVersionString"];
returnversion;
}
//获取服武器版本
-(void)getServerVerson{
NSDictionary* paraDict =@{};
//拼接参数.获取版本号
NSDictionary* postDict = [URLPackedurlFormatWithDict:paraDictA:@"verson"C:@"shops"];
[FuncationpostWithURL:BASEURLparaments:postDictsuccess:^(idresponseObject) {
//判断是否有新版本
// if
(![responseObject[@"verson"] isEqualToString:[self getAPPVerson]])
if(1)
{
//弹出警示控制器
UIAlertController* alert = [UIAlertControlleralertControllerWithTitle:@"有新版本更新"message:nilpreferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* action = [UIAlertActionactionWithTitle:@"取消"style:UIAlertActionStyleCancelhandler:nil];
UIAlertAction* action2 = [UIAlertActionactionWithTitle:@"去App
Store更新"style:UIAlertActionStyleDefaulthandler:^(UIAlertAction*_Nonnullaction) {
[[UIApplicationsharedApplication]openURL:[NSURLURLWithString:SHAREURL]];
}];
[alertaddAction:action];
[alertaddAction:action2];
[selfpresentViewController:alertanimated:YEScompletion:nil];
}
}failure:^(iderror) {
//失败了再次下载版本
[selfgetServerVerson];
}];
}