//检查更新页面
- (void)Renew{
NSDictionary *infoDic = [[NSBundle mainBundle]infoDictionary];
NSString *version = [infoDic valueForKey:@"CFBundleShortVersionString"];
NSString *ipstr = [NSObject deviceIPAdress];
NSString *paramIp = ipstr;
NSTimeInterval time = [[NSDate date]timeIntervalSince1970];
long i = time;
NSString *paramTime = [NSString stringWithFormat:@"%ld",i];
NSString *signstr = [NSString stringWithFormat:@"%@%@%@%@",paramTime,paramIp,@"phone_ios",@"d556bd3337cd909b49eb5e33f46ad65c"];
NSString *md5str = [signstr MD5Hash];
NSString *mdstr = [md5str lowercaseString];
NSString *sign = mdstr;
NSString *key = @"phone_ios";
NSDictionary *param = @{
@"type" : @2,
@"version" : version
};
NSDictionary *dict = @{
@"paramTime" : paramTime,
@"paramIp" : paramIp,
@"sign":sign,
@"key" : key,
@"param":param
};
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.requestSerializer = [AFJSONRequestSerializer serializer];
manager.responseSerializer = [AFJSONResponseSerializer serializer];
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"application/json"];
[manager POST:RenewUrl parameters:dict success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSDictionary *resultDic = responseObject[@"result"];
_upgradeUrl = resultDic[@"upgradeUrl"];
_force = resultDic[@"isForce"];
NSLog(@"_force--------%@",_force);
NSLog(@"%@",resultDic);
if ([resultDic[@"isForce"]compare:@0] !=NSOrderedSame) {
UIAlertView *isForceView = [[UIAlertView alloc]initWithTitle:@"特别提示" message:@"发现新版本" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"下载", nil];
[isForceView show];
}else if ([resultDic[@"version"]compare:version] != NSOrderedSame) {
UIAlertView *resultView = [[UIAlertView alloc]initWithTitle:@"提示" message:@"发现新版本" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"下载", nil];
[resultView show];
}else{
return ;
}
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
UIAlertView *errorView = [[UIAlertView alloc]initWithTitle:@"提示" message:@"网络有问题" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
[errorView show];
NSLog(@"%@",error);
}];
}