Browse Source

checkDeviceCamera 新增方法是否弹窗

Steven 4 months ago
parent
commit
31988bc300

+ 36 - 17
KulexiuForStudent/KulexiuForStudent/Common/Base/WebView/KSBaseWKWebViewController.m

@@ -751,24 +751,43 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
     }
     else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"checkDeviceCamera"]) { // 检测相机权限
         NSMutableDictionary *sendContent = [NSMutableDictionary dictionaryWithDictionary:[parm ks_dictionaryValueForKey:@"content"]];
-        
-        [RecordCheckManager checkCameraPremissionAvaiableCallback:^(PREMISSIONTYPE type) {
-            
-            if (type == PREMISSIONTYPE_YES) {
-                [sendContent setValue:@(YES) forKey:@"status"];
-                NSMutableDictionary *sendParm = [NSMutableDictionary dictionaryWithDictionary:parm];
-                [sendParm setValue:sendContent forKey:@"content"];
-                [self postMessage:sendParm];
+        BOOL hideAlert = [sendContent ks_boolValueForKey:@"hideAlert"];
+
+        if (hideAlert) { // 不需要第一次询问
+            [RecordCheckManager checkCameraPremissionAvaiableWithNoSystemAlertCallback:^(PREMISSIONTYPE type) {
+                if (type == PREMISSIONTYPE_YES) {
+                    [sendContent setValue:@(YES) forKey:@"status"];
+                    NSMutableDictionary *sendParm = [NSMutableDictionary dictionaryWithDictionary:parm];
+                    [sendParm setValue:sendContent forKey:@"content"];
+                    [self postMessage:sendParm];
+                }
+                else if (type == PREMISSIONTYPE_NO) {
+                    [sendContent setValue:@(NO) forKey:@"status"];
+                    NSMutableDictionary *sendParm = [NSMutableDictionary dictionaryWithDictionary:parm];
+                    [sendParm setValue:sendContent forKey:@"content"];
+                    [self postMessage:sendParm];
+                }
+            }];
+        }
+        else {
+            [RecordCheckManager checkCameraPremissionAvaiableCallback:^(PREMISSIONTYPE type) {
+                
+                if (type == PREMISSIONTYPE_YES) {
+                    [sendContent setValue:@(YES) forKey:@"status"];
+                    NSMutableDictionary *sendParm = [NSMutableDictionary dictionaryWithDictionary:parm];
+                    [sendParm setValue:sendContent forKey:@"content"];
+                    [self postMessage:sendParm];
 
-            }
-            else if (type == PREMISSIONTYPE_NO) {
-                [sendContent setValue:@(NO) forKey:@"status"];
-                NSMutableDictionary *sendParm = [NSMutableDictionary dictionaryWithDictionary:parm];
-                [sendParm setValue:sendContent forKey:@"content"];
-                [self postMessage:sendParm];
-                [self showAlertWithMessage:@"请开启相机访问权限" type:CHECKDEVICETYPE_CAMREA];
-            }
-        }];
+                }
+                else if (type == PREMISSIONTYPE_NO) {
+                    [sendContent setValue:@(NO) forKey:@"status"];
+                    NSMutableDictionary *sendParm = [NSMutableDictionary dictionaryWithDictionary:parm];
+                    [sendParm setValue:sendContent forKey:@"content"];
+                    [self postMessage:sendParm];
+                    [self showAlertWithMessage:@"请开启相机访问权限" type:CHECKDEVICETYPE_CAMREA];
+                }
+            }];
+        }
     }
 }