Преглед изворни кода

1.修改iOS Apex CRM增加版本号获取接口。

Pen Li пре 7 година
родитељ
комит
55e9338de4
1 измењених фајлова са 19 додато и 1 уклоњено
  1. 19 1
      RedAnt CRM/APEX CRM/APEX CRM/RAWKWebView.m

+ 19 - 1
RedAnt CRM/APEX CRM/APEX CRM/RAWKWebView.m

@@ -107,7 +107,7 @@
 
     [self.wkwebView.configuration.userContentController addScriptMessageHandler:self name:@"Signature"];
     [self.wkwebView.configuration.userContentController addScriptMessageHandler:self name:@"SelectContact"];
-
+    [self.wkwebView.configuration.userContentController addScriptMessageHandler:self name:@"requestApplicationVersion"];
     //    [self.configuration.userContentController addScriptMessageHandler:self name:@"Color"];
     //    [self.configuration.userContentController addScriptMessageHandler:self name:@"Pay"];
     //    [self.configuration.userContentController addScriptMessageHandler:self name:@"Shake"];
@@ -129,6 +129,7 @@
     [self.wkwebView.configuration.userContentController removeScriptMessageHandlerForName:@"DatetimePicker"];
     [self.wkwebView.configuration.userContentController removeScriptMessageHandlerForName:@"Signature"];
     [self.wkwebView.configuration.userContentController removeScriptMessageHandlerForName:@"SelectContact"];
+    [self.wkwebView.configuration.userContentController removeScriptMessageHandlerForName:@"requestApplicationVersion"];
 }
 - (void)dealloc
 {
@@ -553,6 +554,16 @@
     }];
 }
 
+- (void)ra_requestAppVersion:(NSDictionary *)params {
+    
+    NSDictionary *infoDic = [[NSBundle mainBundle] infoDictionary];
+    NSString *ver = [infoDic objectForKey:@"CFBundleShortVersionString"];
+    NSString *build = [infoDic objectForKey:@"CFBundleVersion"];
+    NSString *appVer = [NSString localizedStringWithFormat:@"Ver: %@ build %@",ver,build];
+    
+    [self returnToWebPage:params value:appVer];
+}
+
 #pragma mark - Utils
 
 - (NSString *)adjustNilString:(NSString *)str {
@@ -748,6 +759,9 @@
     } else if ([message.name isEqualToString:@"SelectContact"]) {
         
         [self handleSelectContact:params];
+    } else if ([message.name isEqualToString:@"requestApplicationVersion"]) {
+        
+        [self handleRequestApplicationVersion:params];
     }
     else
     {
@@ -865,6 +879,10 @@
     [self ra_selectContact:params];
 }
 
+- (void)handleRequestApplicationVersion:(NSDictionary *)params {
+    [self ra_requestAppVersion:params];
+}
+
 #pragma mark - WKNavigationDelegate
 
 - (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation {