Commit f66ab4d8 authored by zhu's avatar zhu

no message

parent f29bab24
...@@ -10,9 +10,14 @@ ...@@ -10,9 +10,14 @@
#import "ICRAppViewControllerManager.h" #import "ICRAppViewControllerManager.h"
#import "ICRURLProtocol.h" #import "ICRURLProtocol.h"
#import "BMKMapManager.h" #import "BMKMapManager.h"
#import "ICRHTTPController.h"
@interface ICRAppDelegate () @interface ICRAppDelegate ()
@property (strong, nonatomic) BMKMapManager *mapManager; @property (strong, nonatomic) BMKMapManager *mapManager;
@property (strong, nonatomic) NSString *version;//本地版本号
@property (strong, nonatomic) NSString *severVersion;//服务器版本号
@property (strong, nonatomic) NSString *severUrl;//Ipa下载地址
@property (assign, nonatomic) BOOL severForceUpdate;//强制更新
@end @end
...@@ -32,25 +37,81 @@ ...@@ -32,25 +37,81 @@
[self setupBMKMapMgr]; [self setupBMKMapMgr];
_m_appViewControllerMgr = [ICRAppViewControllerManager getAppViewControllerManager]; _m_appViewControllerMgr = [ICRAppViewControllerManager getAppViewControllerManager];
#pragma 版本更新 #pragma 版本更新
// [self enterpriseUpdate]; [self enterpriseUpdate];
[self.window makeKeyAndVisible]; [self.window makeKeyAndVisible];
return YES; return YES;
} }
#pragma mark enterprise alertView 企业版提示 #pragma mark enterprise alertView 企业版提示
- (void)enterpriseUpdate{ - (void)enterpriseUpdate{
NSString *currentVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
NSComparisonResult comResult = [self p_compareVersions: currentVersion betweenVersion2:@"后台返回的app版本"];//_versionModel.ClientVersion]; NSString *path = [[NSBundle mainBundle]pathForResource:@"Info" ofType:@"plist"];
NSDictionary* content =[NSDictionary dictionaryWithContentsOfFile:path];
NSString *version = [content valueForKey:@"CFBundleVersion"] ;
self.version=version;
// 获取服务器更新信息
[ self getDataFromServer];
}
//请求服务器更新信息
- (void)getDataFromServer{
__weak typeof(self)weakSelf = self;
void(^succ)(id) = ^(id data) {
[IBTLoadingView hideHUDWithText:nil];
__strong __typeof(weakSelf)strongSelf = weakSelf;
if (data) {
NSInteger success = [data[@"success"] integerValue];
NSString *message = data[@"message"] ;
if (success == 1) {
NSDictionary *dictData = data[@"data"];
NSString*serverVeision=[dictData objectForKey:@"version"];
NSString*serverUrl=[dictData objectForKey:@"url"];
BOOL forceUpdate=[dictData objectForKey:@"forceUpdate"];
self.severVersion=serverVeision;
self.severUrl=serverUrl;
self.severForceUpdate=forceUpdate;
[strongSelf comperVersion];
}else{
[IBTLoadingView showTips:message];
}
}else{
[IBTLoadingView showTips:@" 无记录 "];
}
};
void(^fail)(id) = ^(id data) {
[IBTLoadingView hideHUDWithText:nil];
[IBTLoadingView showTips:data];
};
[IBTLoadingView showProgressLabel:@"正在加载..."];
[[ICRHTTPController sharedController] getVeisionIdWithType:@"ipa" success:succ failure:fail];
}
//比较版本号及是否下载
-(void)comperVersion
{
NSComparisonResult comResult = [self p_compareVersions: self.version betweenVersion2:self.severVersion];
if (comResult == NSOrderedAscending) { if (comResult == NSOrderedAscending) {
//299企业版的更新 @"有新的版本可供下载" //299企业版的更新 @"有新的版本可供下载"
// NSOrderedAscending self.version<self.severVersion
// NSOrderedDescending self.version>self.severVersion
// NSOrderedSame self.version==self.severVersion
if (self.severForceUpdate) {
//强制更新
UIAlertView *alertV = [[UIAlertView alloc]initWithTitle:@"新版本告知" message: @"有新版本发布请您下载最新版本" delegate:self cancelButtonTitle:nil otherButtonTitles: @"去下载", nil];
alertV.tag = 1001;
[alertV show];
}else
{
UIAlertView *alertV = [[UIAlertView alloc]initWithTitle:@"新版本告知" message: @"有新版本发布请您下载最新版本" delegate:self cancelButtonTitle:@"下次再说"otherButtonTitles: @"去下载", nil];//
alertV.tag = 1002;
[alertV show];
}
UIAlertView *alertV = [[UIAlertView alloc]initWithTitle:@"新版本" message: @"" delegate:self cancelButtonTitle:@"下次再说"otherButtonTitles: @"去下载", nil];//_versionModel.UpgradeRemark
// alertV.tag = alertVEnterprise;
// [alertV show];
}else{ }else{
[IBTLoadingView showProgressLabel:@"暂无新版本"]; [IBTLoadingView showProgressLabel:@"暂无新版本"];
...@@ -58,12 +119,19 @@ ...@@ -58,12 +119,19 @@
} }
} }
- (void) alertView:(UIAlertView *)alertView - (void) alertView:(UIAlertView *)alertView
clickedButtonAtIndex:(NSInteger)buttonIndex { clickedButtonAtIndex:(NSInteger)buttonIndex {
if (alertView.tag==1001) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:self.severUrl]];
}else if (alertView.tag==1002)
{
if (buttonIndex == 1) { if (buttonIndex == 1) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"app下载的url"]]; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:self.severUrl]];
} }
}
} }
//比较版本号 //比较版本号
- (NSComparisonResult)p_compareVersions: (NSString *)version1 betweenVersion2: (NSString *)version2{ - (NSComparisonResult)p_compareVersions: (NSString *)version1 betweenVersion2: (NSString *)version2{
......
...@@ -405,7 +405,10 @@ typedef NS_ENUM(NSUInteger, ICRAttachmentType) { ...@@ -405,7 +405,10 @@ typedef NS_ENUM(NSUInteger, ICRAttachmentType) {
-(void)saveReceiptAndReceiveWithData:(id)data -(void)saveReceiptAndReceiveWithData:(id)data
success:(void (^)(id))succ success:(void (^)(id))succ
failure:(void (^)(id))fail; failure:(void (^)(id))fail;
//版本更新
- (void)getVeisionIdWithType:(NSString *)type
success:(void (^)(id))succ
failure:(void (^)(id))fail;
@end @end
......
...@@ -129,8 +129,8 @@ typedef NS_ENUM(NSUInteger, ICRHTTPAction) { ...@@ -129,8 +129,8 @@ typedef NS_ENUM(NSUInteger, ICRHTTPAction) {
//收货单 //收货单
XFFHttp_SaveRctinfo, XFFHttp_SaveRctinfo,
XFFHttp_SaveReceipt, XFFHttp_SaveReceipt,
//版本更新
XFFHttp_getVersionId
}; };
...@@ -243,6 +243,8 @@ static NSString * const ICRHTTPInterface[] = { ...@@ -243,6 +243,8 @@ static NSString * const ICRHTTPInterface[] = {
//收货 //收货
[XFFHttp_SaveRctinfo] =@"transfer/save_rctinfo", [XFFHttp_SaveRctinfo] =@"transfer/save_rctinfo",
[XFFHttp_SaveReceipt] =@"transfer/receipt", [XFFHttp_SaveReceipt] =@"transfer/receipt",
[XFFHttp_getVersionId] = @"ipapk",
}; };
static NSString * const ICRAttachmentTypeValue[] = { static NSString * const ICRAttachmentTypeValue[] = {
...@@ -2916,5 +2918,43 @@ acceptTypeJson:YES ...@@ -2916,5 +2918,43 @@ acceptTypeJson:YES
success:success success:success
failure:failure]; failure:failure];
} }
//版本更新
- (void)getVeisionIdWithType:(NSString *)type
success:(void (^)(id))succ
failure:(void (^)(id))fail
{
if (!type) {
if (fail) {
fail( [[self class] ErrorWithMsg:ERROR_PARAMETER code:0] );
}
return;
}
void (^success)(AFHTTPRequestOperation *operation, id responseObject) = ^(AFHTTPRequestOperation *operation, id responseObject) {
CLog(@"%@", responseObject);
if (succ) {
succ( responseObject );
}
};
void (^failure)(AFHTTPRequestOperation *operation, NSError *error) = ^(AFHTTPRequestOperation *operation, NSError *error) {
CLog(@"%@", error);
if (fail) {
fail( error );
}
};
NSString *urlStr = [[[self class] UrlForPluginHTTPAction:XFFHttp_getVersionId] stringByAppendingFormat:@"?type=%@",type];
NSString *encodeUrlStr = [urlStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[self GET:encodeUrlStr
parameters:nil
needToken:NO
acceptTypeJson:YES
success:success
failure:failure];
}
@end @end
...@@ -2,11 +2,6 @@ ...@@ -2,11 +2,6 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>CFBundleDevelopmentRegion</key> <key>CFBundleDevelopmentRegion</key>
<string>en</string> <string>en</string>
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
...@@ -19,12 +14,15 @@ ...@@ -19,12 +14,15 @@
<string>$(PRODUCT_NAME)</string> <string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>1</string> <string>1.0.2</string>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>NSLocationWhenInUseUsageDescription</key> <key>NSLocationWhenInUseUsageDescription</key>
<string></string> <string></string>
<key>UILaunchStoryboardName</key> <key>UILaunchStoryboardName</key>
......
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