AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
//966061242 密云360
[manager POST:@"http://itunes.apple.com/cn/lookup?id=966061242" parameters:nil success:^(AFHTTPRequestOperation * _Nonnull operation, id _Nonnull responseObject) {
NSLog(@"responseObject:%@", responseObject);
NSArray *array = responseObject[@"results"];
NSDictionary *dict = [array lastObject];
double doubleUpdateVersion = [dict[@"version"] doubleValue];
NSLog(@"当前版本为:%@", dict[@"version"]);
NSDictionary*infoDict=[[NSBundle mainBundle]infoDictionary];
NSString*currentVersion=[infoDict objectForKey:@"CFBundleShortVersionString"];
NSLog(@"currentVersion:%@", currentVersion);
double doubleCurrentVersion=[currentVersion doubleValue];
if(doubleCurrentVersion<doubleUpdateVersion){
[UIAlertView alertViewWithTitle:@"云帮网" message:@"下载更新新的版本" block:^(NSInteger buttonIndex) {
if (buttonIndex == 1) {
NSString *iTunesString = [NSString stringWithFormat:@"http://itunes.apple.com/app/id%@",@"966061242"];
NSURL *iTunesURL = [NSURL URLWithString:iTunesString];
[[UIApplication sharedApplication] openURL:iTunesURL];
}
} cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
}
} failure:^(AFHTTPRequestOperation * _Nullable operation, NSError * _Nonnull error) {
}];