==================獲取新版本,去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 =@{};
//拼接參數(shù).獲取版本號(hào)
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];
}];
}