//检测软件是否需要升级
-(void)checkVersion
{
//新版本
//NSString *newVersion;
NSMutableArray *newVersion = [NSMutableArray array];
//获取本地软件的版本号
NSString *localVersion = [[[NSBundle mainBundle]infoDictionary] objectForKey:@"CFBundleVersion"];
WS(weakself);
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
[manager POST:@"http://itunes.apple.com/lookup?id=1142068114" parameters:nil progress:^(NSProgress * _Nonnull uploadProgress) {
} success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
NSArray *array = responseObject[@"results"];
NSDictionary *dict = [array lastObject];
NSLog(@"当前版本为:%@", dict[@"version"]);
[newVersion addObject:dict[@"version"]];
[weakself isOrUp:localVersion andNew:newVersion[0]];
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
}];
}
/**
* 升级(刨除1.2.2)最后的.2
*/
- (void)isOrUp:(NSString *)old andNew:(NSString *)new{
NSString *msg = [NSString stringWithFormat:@"你当前的版本是V%@,发现新版本V%@,是否下载新版本?",old,new];
MYLog(@"%@",msg);
MYLog(@"%f,%f",[new floatValue],[old floatValue]);
//对比发现的新版本和本地的版本
if ([new floatValue] >= [old floatValue])
{
UIAlertView *createUserResponseAlert = [[UIAlertView alloc] initWithTitle:@"升级提示!" message:msg delegate:self cancelButtonTitle:@"下次再说" otherButtonTitles: @"现在升级", nil];
[createUserResponseAlert show];
}
-(void)checkVersion
{
//新版本
//NSString *newVersion;
NSMutableArray *newVersion = [NSMutableArray array];
//获取本地软件的版本号
NSString *localVersion = [[[NSBundle mainBundle]infoDictionary] objectForKey:@"CFBundleVersion"];
WS(weakself);
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
[manager POST:@"http://itunes.apple.com/lookup?id=1142068114" parameters:nil progress:^(NSProgress * _Nonnull uploadProgress) {
} success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) {
NSArray *array = responseObject[@"results"];
NSDictionary *dict = [array lastObject];
NSLog(@"当前版本为:%@", dict[@"version"]);
[newVersion addObject:dict[@"version"]];
[weakself isOrUp:localVersion andNew:newVersion[0]];
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
}];
}
/**
* 升级(刨除1.2.2)最后的.2
*/
- (void)isOrUp:(NSString *)old andNew:(NSString *)new{
NSString *msg = [NSString stringWithFormat:@"你当前的版本是V%@,发现新版本V%@,是否下载新版本?",old,new];
MYLog(@"%@",msg);
MYLog(@"%f,%f",[new floatValue],[old floatValue]);
//对比发现的新版本和本地的版本
if ([new floatValue] >= [old floatValue])
{
UIAlertView *createUserResponseAlert = [[UIAlertView alloc] initWithTitle:@"升级提示!" message:msg delegate:self cancelButtonTitle:@"下次再说" otherButtonTitles: @"现在升级", nil];
[createUserResponseAlert show];
}
}
//跳转到Appstore
- (void)upApp:(UIButton *)sender{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://itunes.apple.com/cn/app/ding-dongsshn/id??????mt=8"]];
}