Commit 64176b2b authored by 曹云霄's avatar 曹云霄

增加版本控制,强制更新、非强制更新

parent 065f1661
......@@ -42,8 +42,6 @@
@property (weak, nonatomic) IBOutlet UIButton *loginButton;
/**
* 用户名背景View
*/
......
......@@ -35,8 +35,6 @@
*/
@property (nonatomic,strong) NSTimer *sendTimer;
/**
* 用户名
*/
......@@ -98,7 +96,9 @@
self.passWordString = [[NSUserDefaults standardUserDefaults] objectForKey:PASSWORD];
self.userName.text = self.userNameString;
self.passWord.text = self.passWordString;
//版本更新
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(detectionUpdateVersion) name:UPLOADVERSION object:nil];
[self detectionUpdateVersion];
}
......@@ -475,22 +475,37 @@
self.identityView.verificationCode.text = @"";
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
#pragma mark - 检测更新
- (void)detectionUpdateVersion
{
NSString *path = [[NSBundle mainBundle]pathForResource:@"Info" ofType:@"plist"];
NSDictionary* content =[NSDictionary dictionaryWithContentsOfFile:path];
NSString *version = [content valueForKey:@"CFBundleShortVersionString"];
//获取服务端版本大小
WS(weakSelf);
NSString *string = [NSString stringWithFormat:@"/employee/getUpgrade?apptype=IOS&version=%@",version];
[[NetworkRequestClassManager Manager] NetworkWithDictionaryRequestWithURL:SERVERREQUESTURL(string) WithRequestType:1 WithParameter:nil WithReturnValueBlock:^(id returnValue) {
if ([returnValue[@"code"] isEqualToNumber:@0]) {
NSDictionary *dict = returnValue[@"data"];
UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"提示" message:@"发现新版本,快去更新吧!" preferredStyle:UIAlertControllerStyleAlert];
[alertVC addAction:[UIAlertAction actionWithTitle:@"我知道了" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:dict[@"url"]]];
}]];
//是否强制更新
if (![dict[@"forceupdate"] isEqualToString:@"yes"]) {
[alertVC addAction:[UIAlertAction actionWithTitle:@"以后再说" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
[weakSelf dismissViewControllerAnimated:YES completion:nil];
}]];
}
[weakSelf presentViewController:alertVC animated:YES completion:nil];
}
} WithErrorCodeBlock:^(id errorCodeValue) {
[weakSelf ErrorMBProgressView:@"网络不可用,请检查网络连接"];
} WithFailureBlock:^(NSError *error) {
[weakSelf ErrorMBProgressView:error.localizedDescription];
}];
}
*/
@end
......@@ -1753,9 +1753,9 @@
);
PRODUCT_BUNDLE_IDENTIFIER = com.gomore.opple;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "e9bd3600-5e9c-4cd0-a0d5-b7d8b0882ca8";
PROVISIONING_PROFILE = "61a46754-eb25-444b-8967-2414b22659dc";
STRIP_PNG_TEXT = NO;
TARGETED_DEVICE_FAMILY = 2;
TARGETED_DEVICE_FAMILY = "1,2";
USER_HEADER_SEARCH_PATHS = "$(PODS_ROOT)/**";
};
name = Debug;
......@@ -1811,9 +1811,9 @@
);
PRODUCT_BUNDLE_IDENTIFIER = com.gomore.opple;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "e9bd3600-5e9c-4cd0-a0d5-b7d8b0882ca8";
PROVISIONING_PROFILE = "61a46754-eb25-444b-8967-2414b22659dc";
STRIP_PNG_TEXT = NO;
TARGETED_DEVICE_FAMILY = 2;
TARGETED_DEVICE_FAMILY = "1,2";
USER_HEADER_SEARCH_PATHS = "$(PODS_ROOT)/**";
};
name = Release;
......
......@@ -22,11 +22,11 @@
// Override point for customization after application launch.
//bug检测
[Bugly startWithAppId:@"900033734"];
// [self performSelector:@selector(KclickAction) withObject:self afterDelay:3];
//检测版本更新
[self detectionNetwork];
[self SetIQKeyboardManager];
[self RootViewcontroller];
[self detectionNetwork];
[self setUMShare];
[self setUMShare];
return YES;
}
......@@ -56,9 +56,9 @@
UIStoryboard *story = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
LoginViewController *login = [story instantiateViewControllerWithIdentifier:@"Login"];
self.window.rootViewController = login;
}
#pragma mark -接收到内存警告
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application
{
......@@ -81,7 +81,7 @@
#pragma mark -检测网络的可连接性
- (void)detectionNetwork
{
self.Networkstatus = true;
[[AFNetworkReachabilityManager sharedManager] startMonitoring];
[[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
......@@ -113,6 +113,51 @@
}];
}
/**
* 比较版本号
*
* @param v1 第一个版本号
* @param v2 第二个版本号
*
* @return 如果版本号相等,返回 0,
* 如果第一个版本号低于第二个,返回 -1,否则返回 1.
*/
int compare_version(const char *v1, const char *v2)
{
assert(v1);
assert(v2);
const char *p_v1 = v1;
const char *p_v2 = v2;
while (*p_v1 && *p_v2) {
char buf_v1[32] = {0};
char buf_v2[32] = {0};
char *i_v1 = strchr(p_v1, '.');
if (!i_v1) break;
if (i_v1 != p_v1) {
strncpy(buf_v1, p_v1, i_v1 - p_v1);
p_v1 = i_v1;
}
else
p_v1++;
char *i_v2 = strchr(p_v2, '.');
if (!i_v2) break;
if (i_v2 != p_v2) {
strncpy(buf_v2, p_v2, i_v2 - p_v2);
p_v2 = i_v2;
}
else
p_v2++;
int order = atoi(buf_v1) - atoi(buf_v2);
if (order != 0)
return order < 0 ? -1 : 1;
}
double res = atof(p_v1) - atof(p_v2);
if (res < 0) return -1;
if (res > 0) return 1;
return 0;
}
-(void)setUMShare
{
// 友盟分享初始化
......@@ -128,6 +173,15 @@
// [UMSocialQQHandler setQQWithAppId:@"AppId" appKey:@"appSecret" url:@"url链接"];
}
#pragma mark -更新通知
- (void)updateVersion
{
[[NSNotificationCenter defaultCenter] postNotificationName:UPLOADVERSION object:nil];
}
- (void)applicationWillResignActive:(UIApplication *)application {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
......@@ -140,6 +194,7 @@
- (void)applicationWillEnterForeground:(UIApplication *)application {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
[self updateVersion];
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
......
......@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.4</string>
<string>1.0.5</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleURLTypes</key>
......@@ -78,6 +78,10 @@
</array>
<key>UIStatusBarHidden</key>
<true/>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationLandscapeLeft</string>
......
......@@ -56,7 +56,7 @@
- (void)SuccessMBProgressView:(NSString *)successString;
/**
* 失败等待视图
* 提示信息等待视图
*/
- (void)ErrorMBProgressView:(NSString *)errorString;
......
......@@ -183,23 +183,9 @@
[hud hide:YES afterDelay:1];
}
#pragma mark -显示错误的提示框
#pragma mark -显示信息的提示框
- (void)ErrorMBProgressView:(NSString *)errorString
{
// MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view.window animated:YES];
// // Set the custom view mode to show any view.
// hud.mode = MBProgressHUDModeText;
// // Set an image view with a checkmark.
//// UIImage *image = [[UIImage imageNamed:@"Error"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
//// hud.customView = [[UIImageView alloc] initWithImage:image];
// // Looks a bit nicer if we make it square.
//// hud.square = YES;
// // Optional label text.
//// hud.activityIndicatorColor = kMainBlueColor;
// hud.labelFont = [UIFont systemFontOfSize:12];
// hud.labelText = errorString;
// [hud hide:YES afterDelay:1];
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.labelText = errorString;
hud.margin = 10.f;
......
......@@ -187,10 +187,10 @@
*/
#define SAVEVISITEDTIME @"/consumer/saveLastVisitedTime?consumerId="
/**
* 获取版本升级信息
*/
#define VERSION @"/employee/getUpgrade?"
......
......@@ -37,11 +37,11 @@ typedef enum {
/**
* 网络请求
* 网络请求传入JSONModel对象
*
* @param requestURLString 网址
* @param requestType 请求类型
* @param parameter JAstor对象
* @param parameter JSONModel对象
* @param sueecssBlock 成功回调
* @param errorCodeBlock 错误编码回调
* @param failureBlock 失败回调
......@@ -59,7 +59,7 @@ typedef enum {
/**
* 网络请求
* 网络请求传入字典对象
*
* @param requestURLString 网址
* @param requestType 请求类型
......
......@@ -191,7 +191,10 @@
*/
#define WS(weakSelf) __weak __typeof(&*self)weakSelf = self
/**
* 更新版本通知
*/
#define UPLOADVERSION @"uploadVersion"
......
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