//拼接查询参数进行查询
NSString *url = [NSString stringWithFormat:@"https://itunes.apple.com/search?term=%@&entity=software&sort=recent&limit=1", @"喜马拉雅FM"];
//将中文进行转码 NSString *encodeUrl = [url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
//发送Get请求
[HttpEngineTool HttpGETRequest:encodeUrl success:^(id responseDic) { self.versionArr = responseDic[@"results"];
NSString *version = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
NSString *serverVersion = self.versionArr[0][@"version"];
//trackViewUrl为当前app的信息页
NSString *openUrl = self.versionArr[0][@"trackViewUrl"];
if ([version floatValue] < [serverVersion floatValue]) {
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"有新版本升级" preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *ok = [UIAlertAction actionWithTitle:@"好的" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:openUrl]]; }];
UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { }];
[alert addAction:ok];
[alert addAction:cancel];
[self.window.rootViewController presentViewController:alert animated:YES completion:nil];