Commit c8f43cb9 authored by admin's avatar admin

版本更新

parent e4100e20
......@@ -72,14 +72,15 @@
{
HttpClient *httpCilent = [[HttpClient alloc] initWithUrl:[NSString stringWithFormat:@"%@%@", kRedStarURL, kCheckUpdateURL]];
[httpCilent checkAndUpdateCurrentVersionWithCompletion:^(id response, NSError *error) {
NSLog(@"检查更新 = %@", response);
if (response[@"data"] == nil && response[@"data"] == NULL && response[@"data"] == [NSNull null]) {
return;
} else {
NSDictionary *dict = response[@"data"];
NSString *newVersion = [NSString stringWithFormat:@"%@", dict[@"version"]];
self.jumpURL = [NSString stringWithFormat:@"%@", dict[@"url"]];
NSLog(@"newVersion = %@, _jumpURL = %@", newVersion, _jumpURL);
[self checkAppUpdate:newVersion];
} else {
return;
}
}];
}
......@@ -93,6 +94,7 @@
if (![currentVersion isEqualToString:newVersion]) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示!" message:[NSString stringWithFormat:@"发现新版本:%@", newVersion] delegate:self cancelButtonTitle:@"稍后再说" otherButtonTitles:@"前往更新", nil];
alert.delegate = self;
[alert show];
alert.tag = 3058284;
}
......
......@@ -11,7 +11,9 @@
#import "MineTableFooterView.h"
#define kMineTableViewCell @"mineTableViewCell"
@interface MineViewController () <UITableViewDelegate, UITableViewDataSource>
#import "HttpClient.h"
@interface MineViewController () <UITableViewDelegate, UITableViewDataSource, UIAlertViewDelegate>
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSMutableArray *titleArray;
......@@ -20,6 +22,8 @@
@property (nonatomic, strong) MineTableHeaderView *headView;
@property (nonatomic, strong) MineTableFooterView *footView;
@property (nonatomic, copy) NSString *jumpURL;
@end
@implementation MineViewController
......@@ -44,7 +48,7 @@
self.view.backgroundColor = kSectionBackGroundColor;
self.titleArray = [NSMutableArray arrayWithObjects:@"修改密码",@"配置",@"帮助与反馈",@"关于",@"检查版本更新", nil];
self.titleArray = [NSMutableArray arrayWithObjects:@"配置项目",@"配置",@"帮助与反馈",@"关于",@"检查版本更新", nil];
[self setupTableView];
......@@ -95,6 +99,53 @@
[self.tabBarController dismissViewControllerAnimated:YES completion:nil];
}
#pragma mark - Private Methods
// 获取版本
- (void)getVersion
{
HttpClient *httpCilent = [[HttpClient alloc] initWithUrl:[NSString stringWithFormat:@"%@%@", kRedStarURL, kCheckUpdateURL]];
[httpCilent checkAndUpdateCurrentVersionWithCompletion:^(id response, NSError *error) {
NSLog(@"检查更新 = %@", response);
if (response[@"data"] == nil && response[@"data"] == NULL && response[@"data"] == [NSNull null]) {
return;
} else {
NSDictionary *dict = response[@"data"];
NSString *newVersion = [NSString stringWithFormat:@"%@", dict[@"version"]];
self.jumpURL = [NSString stringWithFormat:@"%@", dict[@"url"]];
NSLog(@"newVersion = %@, _jumpURL = %@", newVersion, _jumpURL);
[self checkAppUpdate:newVersion];
}
}];
}
- (void)checkAppUpdate:(NSString *)newVersion
{
// 获取当前版本
NSDictionary *infoDic = [[NSBundle mainBundle] infoDictionary];
NSString *currentVersion = [NSString stringWithFormat:@"%@",infoDic[@"CFBundleShortVersionString"]];
NSLog(@"当前版本是:%@", currentVersion);
if (![currentVersion isEqualToString:newVersion]) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示!" message:[NSString stringWithFormat:@"发现新版本:%@", newVersion] delegate:self cancelButtonTitle:@"稍后再说" otherButtonTitles:@"前往更新", nil];
alert.delegate = self;
[alert show];
alert.tag = 3058284;
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示!" message:[NSString stringWithFormat:@"当前已经是最新版本!"] delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
[alert show];
}
}
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 1 && alertView.tag == 3058284) {
NSString *url = self.jumpURL;
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
}
}
#pragma mark - TableView Delegate/DataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
......@@ -116,6 +167,13 @@
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row == 4) {
[self getVersion];
}
}
// cell的高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment