|
@@ -6,30 +6,34 @@
|
|
|
//
|
|
|
|
|
|
#import "KSBaseWKWebViewController.h"
|
|
|
-#import "JPUSHService.h"
|
|
|
-#import "LoginViewController.h"
|
|
|
-#import "AppDelegate.h"
|
|
|
-#import "CustomNavViewController.h"
|
|
|
-#import "UIDevice+TFDevice.h"
|
|
|
-#import "KSPremissionAlert.h"
|
|
|
-#import "RecordCheckManager.h"
|
|
|
+#import "WebViewBaseConfig.h" // 基础配置
|
|
|
+#import "UIDevice+TFDevice.h" // 横竖屏
|
|
|
+
|
|
|
+// 其他web
|
|
|
#import "KSLocalWebViewController.h"
|
|
|
#import "KSAccompanyWebViewController.h"
|
|
|
-#import "KSChatConversationViewController.h"
|
|
|
-#import "KSGroupConversationController.h"
|
|
|
+
|
|
|
+#import "AppDelegate+AppService.h"
|
|
|
+#import "UserInfoManager.h"
|
|
|
+#import "KSMediaManager.h"
|
|
|
+#import "KSUMShareManager.h"
|
|
|
#import "KSOrderManager.h"
|
|
|
-#import "AddressListViewController.h"
|
|
|
#import "KSEnterLiveroomManager.h"
|
|
|
|
|
|
-#import "TZImageManager.h"
|
|
|
-#import <AVFoundation/AVFoundation.h>
|
|
|
-#import "KSDocumentViewController.h"
|
|
|
+// 保存文件
|
|
|
#import "KSICloudManager.h"
|
|
|
-#import "KSMediaManager.h"
|
|
|
-#import "KSUMShareManager.h"
|
|
|
-#import "UserInfoManager.h"
|
|
|
-#import "KSWebLoadRefreshView.h"
|
|
|
+#import "KSDocumentViewController.h"
|
|
|
+
|
|
|
+// 聊天页面
|
|
|
+#import "KSChatConversationViewController.h"
|
|
|
+#import "KSGroupConversationController.h"
|
|
|
+
|
|
|
+#import "AddressListViewController.h"
|
|
|
+
|
|
|
+// 视频封面选择
|
|
|
#import "KSVideoCropViewController.h"
|
|
|
+// 错误刷新web 页面
|
|
|
+#import "KSWebLoadRefreshView.h"
|
|
|
|
|
|
typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
CHOOSETYPE_XML,
|
|
@@ -44,14 +48,10 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
|
|
|
@property (nonatomic,weak) CALayer *progressLayer;
|
|
|
|
|
|
-@property (nonatomic, strong) NSString *currerntURL; // 当前web URL
|
|
|
-
|
|
|
@property (nonatomic, assign) BOOL hasModify;
|
|
|
|
|
|
@property (nonatomic, assign) BOOL hasChangeSource; // 是否切换了亮屏,横屏等配置
|
|
|
|
|
|
-@property (nonatomic, assign) BOOL landScape;
|
|
|
-
|
|
|
/// 选择本地文件 parm
|
|
|
@property (nonatomic, strong) NSMutableDictionary *chooseFileParm;
|
|
|
|
|
@@ -86,39 +86,6 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(captureViewTips:) name:UIScreenCapturedDidChangeNotification object:nil];
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-- (void)captureViewTips:(NSNotification *)notification {
|
|
|
- [self checkCaptured];
|
|
|
-}
|
|
|
-
|
|
|
-- (void)checkCaptured {
|
|
|
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
- if ([self checkIsCaptured]) {
|
|
|
- [self didCapturedView];
|
|
|
- }
|
|
|
- });
|
|
|
-}
|
|
|
-#pragma mark ---- 镜像和投屏检测
|
|
|
-- (BOOL)checkIsCaptured {
|
|
|
- if ([UIScreen mainScreen].isCaptured && [UIScreen screens].count < 2) {
|
|
|
- return YES;
|
|
|
- }
|
|
|
- return NO;
|
|
|
-}
|
|
|
-
|
|
|
-- (void)didCapturedView {
|
|
|
-
|
|
|
- NSMutableDictionary *sendParm = [NSMutableDictionary dictionary];
|
|
|
- [sendParm setValue:@"setVideoPlayer" forKey:@"api"];
|
|
|
- NSMutableDictionary *content = [NSMutableDictionary dictionary];
|
|
|
- [content setValue:@"pause" forKey:@"status"];
|
|
|
- [sendParm setValue:content forKey:@"content"];
|
|
|
- [self postMessage:sendParm];
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- (void)operationDealCallbackMessage:(NSNotification *)notification {
|
|
|
NSString *status = [notification object];
|
|
|
NSMutableDictionary *sendParm = [NSMutableDictionary dictionary];
|
|
@@ -166,9 +133,7 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
}
|
|
|
self.isFirstLoad = NO;
|
|
|
|
|
|
- if ([UIScreen mainScreen].isCaptured) {
|
|
|
- [self didCapturedView];
|
|
|
- }
|
|
|
+ [self checkCaptured];
|
|
|
}
|
|
|
|
|
|
|
|
@@ -224,7 +189,7 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
WeakWebViewScriptMessageDelegate *weakScriptMessageDelegate = [[WeakWebViewScriptMessageDelegate alloc] initWithDelegate:self];
|
|
|
//这个类主要用来做native与JavaScript的交互管理
|
|
|
WKUserContentController * wkUController = [[WKUserContentController alloc] init];
|
|
|
- [wkUController addScriptMessageHandler:weakScriptMessageDelegate name:@"COLEXIU"];
|
|
|
+ [wkUController addScriptMessageHandler:weakScriptMessageDelegate name:SCRIPT_NAME];
|
|
|
config.userContentController = wkUController;
|
|
|
|
|
|
WKPreferences *preferences = [WKPreferences new];
|
|
@@ -239,28 +204,23 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
_myWebView.scrollView.bounces = NO;
|
|
|
_myWebView.scrollView.showsVerticalScrollIndicator = NO;
|
|
|
_myWebView.scrollView.showsHorizontalScrollIndicator = NO;
|
|
|
+ [self.view addSubview:_myWebView];
|
|
|
+#ifdef DEBUG
|
|
|
+ if (@available(iOS 16.4, *)) {
|
|
|
+ _myWebView.inspectable = YES;
|
|
|
+ }
|
|
|
+#endif
|
|
|
// 加载进度条和title
|
|
|
[_myWebView addObserver:self forKeyPath:@"estimatedProgress" options:NSKeyValueObservingOptionNew context:nil];
|
|
|
-
|
|
|
+ [_myWebView addObserver:self forKeyPath:@"title" options:NSKeyValueObservingOptionNew context:NULL];
|
|
|
[self.view addSubview:_myWebView];
|
|
|
-
|
|
|
-// // OC
|
|
|
-// if (@available(iOS 16.4, *)) {
|
|
|
-// _myWebView.inspectable = true;
|
|
|
-// } else {
|
|
|
-// // Fallback on earlier versions
|
|
|
-// }
|
|
|
-
|
|
|
[_myWebView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
make.left.right.mas_equalTo(self.view);
|
|
|
make.top.mas_equalTo(self.view.mas_top);
|
|
|
make.bottom.mas_equalTo(self.view.mas_bottom);
|
|
|
}];
|
|
|
- if (@available(iOS 11.0, *)) {
|
|
|
- _myWebView.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
|
|
- } else {
|
|
|
- // Fallback on earlier versions
|
|
|
- }
|
|
|
+ _myWebView.scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
|
|
+
|
|
|
[self setupProgress];
|
|
|
// 修改userAgent
|
|
|
[self loadRequest];
|
|
@@ -272,12 +232,11 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
|
|
|
- (void)configUserAgent:(WKWebViewConfiguration *)config {
|
|
|
NSString *oldUserAgent = config.applicationNameForUserAgent;
|
|
|
- NSString *newAgent = [NSString stringWithFormat:@"%@ %@ %@",oldUserAgent,@"COLEXIUAPPI",@"COLEXIUSTUDENT"];
|
|
|
+ NSString *newAgent = [NSString stringWithFormat:@"%@ %@ %@",oldUserAgent,AGENT_NAME,AGENT_DOMAIN];
|
|
|
config.applicationNameForUserAgent = newAgent;
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
- (void)loadRequest {
|
|
|
|
|
|
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:self.url] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60.0f];
|
|
@@ -303,6 +262,22 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
}
|
|
|
|
|
|
#pragma mark --- 返回按钮的处理
|
|
|
+
|
|
|
+- (void)backPreViewAction {
|
|
|
+ [self.myWebView stopLoading];
|
|
|
+ if (_backRootView) {
|
|
|
+ [self.navigationController popToRootViewControllerAnimated:NO];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ else if (_isBackPreView) {
|
|
|
+ [self.navigationController popViewControllerAnimated:YES];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ [self.navigationController popViewControllerAnimated:YES];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
- (void)backAction {
|
|
|
[self.myWebView stopLoading];
|
|
|
if (_backRootView) {
|
|
@@ -326,7 +301,7 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
- (void)userContentController:(WKUserContentController *)userContentController
|
|
|
didReceiveScriptMessage:(WKScriptMessage *)message {
|
|
|
|
|
|
- if ([message.name isEqualToString:@"COLEXIU"]) {
|
|
|
+ if ([message.name isEqualToString:SCRIPT_NAME]) {
|
|
|
NSDictionary *parm = [self convertJsonStringToNSDictionary:message.body];
|
|
|
// 回到主线程
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
@@ -337,8 +312,7 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
|
|
|
- (void)handleScriptMessageSource:(NSDictionary *)parm {
|
|
|
if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"back"]) { // 返回
|
|
|
- [self.myWebView stopLoading];
|
|
|
- [self.navigationController popViewControllerAnimated:YES];
|
|
|
+ [self backPreViewAction];
|
|
|
}
|
|
|
else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"goBack"]) { // 逐级返回
|
|
|
[self backAction];
|
|
@@ -355,10 +329,8 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
detailCtrl.parmDic = valueDic;
|
|
|
NSInteger orientation = [valueDic ks_integerValueForKey:@"orientation"];
|
|
|
BOOL isLandScape = orientation == 0 ? YES : NO;
|
|
|
- if (isLandScape == self.landScape) {
|
|
|
- self.keepOrientation = YES;
|
|
|
- detailCtrl.keepOrientation = YES;
|
|
|
- }
|
|
|
+ detailCtrl.ks_landScape = isLandScape;
|
|
|
+
|
|
|
[self postMessage:parm];
|
|
|
[self.navigationController pushViewController:detailCtrl animated:YES];
|
|
|
}
|
|
@@ -447,45 +419,6 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
//
|
|
|
[self shareFunctionWithParm:parm];
|
|
|
}
|
|
|
- else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"getNavHeight"]) { // 获取状态栏高度和 title heigt
|
|
|
- NSDictionary *valueDic = [parm ks_dictionaryValueForKey:@"content"];
|
|
|
- [valueDic setValue:[NSNumber numberWithFloat:STATUS_GAP*2] forKey:@"navHeight"];
|
|
|
- [valueDic setValue:@(44*2) forKey:@"titleHeight"];
|
|
|
- [parm setValue:valueDic forKey:@"content"];
|
|
|
- [self postMessage:parm];
|
|
|
- }
|
|
|
- else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"backIconChange"]) {
|
|
|
- /*
|
|
|
- NSDictionary *valueDic = [parm ks_dictionaryValueForKey:@"content"];
|
|
|
- NSString *backColor = [valueDic ks_stringValueForKey:@"iconStyle"];
|
|
|
- NSString *backImage = @"";
|
|
|
- if ([backColor isEqualToString:@"black"]) {
|
|
|
- backImage = @"back_black";
|
|
|
- }
|
|
|
- else {
|
|
|
- backImage = @"back_button_white";
|
|
|
- }
|
|
|
- [self.webBackButton.backButton setImage:[UIImage imageNamed:backImage] forState:UIControlStateNormal];
|
|
|
- // 是否隐藏按钮
|
|
|
- BOOL hideButton = [valueDic ks_boolValueForKey:@"backIconHide"];
|
|
|
- self.webBackButton.hidden = hideButton;
|
|
|
- */
|
|
|
- }
|
|
|
- else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"setBarStatus"]) { // 顶部是否隐藏
|
|
|
- /*
|
|
|
- NSDictionary *valueDic = [parm ks_dictionaryValueForKey:@"content"];
|
|
|
- BOOL isShow = [valueDic ks_boolValueForKey:@"status"]; // 0 隐藏 1 显示
|
|
|
- self.hiddenNavBar = !isShow;
|
|
|
- CGFloat navHeight = isShow ? kNaviBarHeight : 0;
|
|
|
- [self.navView mas_updateConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.height.mas_equalTo(navHeight);
|
|
|
- }];
|
|
|
-
|
|
|
- [self.myWebView mas_updateConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.top.mas_equalTo(self.view.mas_top).offset(navHeight);
|
|
|
- }];
|
|
|
- */
|
|
|
- }
|
|
|
else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"setStatusBarTextColor"]) { // 设置状态栏颜色
|
|
|
NSDictionary *valueDic = [parm ks_dictionaryValueForKey:@"content"];
|
|
|
BOOL whiteColor = [valueDic ks_boolValueForKey:@"statusBarTextColor"];
|
|
@@ -501,18 +434,14 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"paymentOrder"]) {
|
|
|
- NSDictionary *content = [parm ks_dictionaryValueForKey:@"content"];
|
|
|
- NSString *channel = [content ks_stringValueForKey:@"payChannel"];
|
|
|
- if ([channel isEqualToString:@"ali_app"]) {
|
|
|
- NSString *infoMessage = [content ks_stringValueForKey:@"payInfo"];
|
|
|
- [KSOrderManager dealWithAliSDK:infoMessage];
|
|
|
- }
|
|
|
- else if ([channel isEqualToString:@"wx_app"]) {
|
|
|
- NSString *infoMessage = [content ks_stringValueForKey:@"payInfo"];
|
|
|
- [KSOrderManager dealWithWXSDK:infoMessage];
|
|
|
- }
|
|
|
+ else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"getNavHeight"]) { // 获取状态栏高度和 title heigt
|
|
|
+ NSDictionary *valueDic = [parm ks_dictionaryValueForKey:@"content"];
|
|
|
+ [valueDic setValue:[NSNumber numberWithFloat:STATUS_GAP*2] forKey:@"navHeight"];
|
|
|
+ [valueDic setValue:@(44*2) forKey:@"titleHeight"];
|
|
|
+ [parm setValue:valueDic forKey:@"content"];
|
|
|
+ [self postMessage:parm];
|
|
|
}
|
|
|
+
|
|
|
else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"joinChatGroup"]) {
|
|
|
NSDictionary *valueDic = [parm ks_dictionaryValueForKey:@"content"];
|
|
|
NSString *targetId = [valueDic ks_stringValueForKey:@"id"];
|
|
@@ -523,7 +452,6 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
KSChatConversationViewController *ctrl = [[KSChatConversationViewController alloc] init];
|
|
|
ctrl.conversation = model;
|
|
|
[self.navigationController pushViewController:ctrl animated:YES];
|
|
|
-
|
|
|
}
|
|
|
else if ([[valueDic ks_stringValueForKey:@"type"] isEqualToString:@"multi"]) { // 群聊
|
|
|
if ([NSString isEmptyString:targetId]) {
|
|
@@ -554,14 +482,6 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
}];
|
|
|
[self.navigationController pushViewController:ctrl animated:YES];
|
|
|
}
|
|
|
- else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"joinLiveRoom"]) { // 进入直播间
|
|
|
- NSDictionary *valueDic = [parm ks_dictionaryValueForKey:@"content"];
|
|
|
- NSString *roomId = [valueDic ks_stringValueForKey:@"roomId"];
|
|
|
- [LOADING_MANAGER showHUD];
|
|
|
- [KSEnterLiveroomManager joinLiveWithRoomId:roomId inController:(CustomNavViewController *)self.navigationController callback:^{
|
|
|
- [LOADING_MANAGER removeHUD];
|
|
|
- }];
|
|
|
- }
|
|
|
else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"savePicture"]) { // 保存图片到相册
|
|
|
// 判断相册权限
|
|
|
PREMISSIONTYPE albumEnable = [RecordCheckManager checkPhotoLibraryPremissionAvaiable:NO showInView:nil];
|
|
@@ -599,23 +519,83 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
NSDictionary *valueDic = [parm ks_dictionaryValueForKey:@"content"];
|
|
|
NSString *type = [valueDic ks_stringValueForKey:@"type"];
|
|
|
if ([type isEqualToString:@"video"]) {
|
|
|
- NSString *status = [UIScreen mainScreen].isCaptured ? @"1" : @"0";
|
|
|
- NSMutableDictionary *sendParm = [NSMutableDictionary dictionary];
|
|
|
- [sendParm setValue:@"getDeviceStatus" forKey:@"api"];
|
|
|
- NSMutableDictionary *content = [NSMutableDictionary dictionary];
|
|
|
- [content setValue:[valueDic ks_stringValueForKey:@"type"] forKey:@"type"];
|
|
|
- [content setValue:[valueDic ks_stringValueForKey:@"uuid"] forKey:@"uuid"];
|
|
|
- [content setValue:status forKey:@"status"];
|
|
|
- [sendParm setValue:content forKey:@"content"];
|
|
|
- [self postMessage:sendParm];
|
|
|
- if ([status isEqualToString:@"1"]) {
|
|
|
- [LOADING_MANAGER MBShowAUTOHidingInWindow:@"为了保证数据安全,请不要录屏"];
|
|
|
- }
|
|
|
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
+ NSString *status;
|
|
|
+ if ([self checkIsCaptured]) {
|
|
|
+ status = @"1";
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ status = @"0";
|
|
|
+ }
|
|
|
+ NSMutableDictionary *sendParm = [NSMutableDictionary dictionary];
|
|
|
+ [sendParm setValue:@"getDeviceStatus" forKey:@"api"];
|
|
|
+ NSMutableDictionary *content = [NSMutableDictionary dictionary];
|
|
|
+ [content setValue:[valueDic ks_stringValueForKey:@"type"] forKey:@"type"];
|
|
|
+ [content setValue:[valueDic ks_stringValueForKey:@"uuid"] forKey:@"uuid"];
|
|
|
+ [content setValue:status forKey:@"status"];
|
|
|
+ [sendParm setValue:content forKey:@"content"];
|
|
|
+ [self postMessage:sendParm];
|
|
|
+ if ([status isEqualToString:@"1"]) {
|
|
|
+ [LOADING_MANAGER MBShowAUTOHidingInWindow:@"为了保证数据安全,请不要录屏"];
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
- else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"setEventTracking"]) {
|
|
|
- NSString *type = [[parm ks_dictionaryValueForKey:@"content"] ks_stringValueForKey:@"type"];
|
|
|
- [USER_MANAGER sendUMEvent:type];
|
|
|
+ else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"callPhone"]) {
|
|
|
+ NSDictionary *valueDic = [parm ks_dictionaryValueForKey:@"content"];
|
|
|
+ NSString *phone = [valueDic ks_stringValueForKey:@"phone"];
|
|
|
+ [self CallPhoneWith:phone];
|
|
|
+ }
|
|
|
+ else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"setCache"]) {
|
|
|
+ NSDictionary *valueDic = [parm ks_dictionaryValueForKey:@"content"];
|
|
|
+ NSString *key = [valueDic ks_stringValueForKey:@"key"];
|
|
|
+ NSString *value = [valueDic ks_stringValueForKey:@"value"];
|
|
|
+ UserDefaultSetObjectForKey(value, key);
|
|
|
+ }
|
|
|
+ else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"getCache"]) {
|
|
|
+ NSDictionary *valueDic = [parm ks_dictionaryValueForKey:@"content"];
|
|
|
+ NSString *key = [valueDic ks_stringValueForKey:@"key"];
|
|
|
+ NSString *value = UserDefault(key);
|
|
|
+
|
|
|
+ NSMutableDictionary *parm = [NSMutableDictionary dictionaryWithDictionary:valueDic];
|
|
|
+ [parm setValue:value forKey:@"value"];
|
|
|
+ NSMutableDictionary *sendParm = [NSMutableDictionary dictionary];
|
|
|
+ [sendParm setValue:@"getCache" forKey:@"api"];
|
|
|
+ [sendParm setValue:parm forKey:@"content"];
|
|
|
+ [self postMessage:sendParm];
|
|
|
+ }
|
|
|
+ else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"isInstall"]) {
|
|
|
+ NSDictionary *valueDic = [parm ks_dictionaryValueForKey:@"content"];
|
|
|
+ NSString *type = [valueDic ks_stringValueForKey:@"type"];
|
|
|
+
|
|
|
+ NSURL *url = [NSURL URLWithString:type];
|
|
|
+ BOOL canOpen = [[UIApplication sharedApplication] canOpenURL:url];
|
|
|
+ NSInteger installStatus = canOpen ? 1 : 0;
|
|
|
+
|
|
|
+ NSMutableDictionary *parm = [NSMutableDictionary dictionaryWithDictionary:valueDic];
|
|
|
+ [parm setValue:@(installStatus) forKey:@"installStatus"];
|
|
|
+ NSMutableDictionary *sendParm = [NSMutableDictionary dictionary];
|
|
|
+ [sendParm setValue:@"isInstall" forKey:@"api"];
|
|
|
+ [sendParm setValue:parm forKey:@"content"];
|
|
|
+ [self postMessage:sendParm];
|
|
|
+ }
|
|
|
+ else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"openApp"]) {
|
|
|
+ NSDictionary *valueDic = [parm ks_dictionaryValueForKey:@"content"];
|
|
|
+ NSString *type = [valueDic ks_stringValueForKey:@"type"];
|
|
|
+
|
|
|
+ NSURL *url = [NSURL URLWithString:type];
|
|
|
+ if ([[UIApplication sharedApplication] canOpenURL:url]) {
|
|
|
+ [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"downloadApp"]) {
|
|
|
+ NSDictionary *valueDic = [parm ks_dictionaryValueForKey:@"content"];
|
|
|
+ NSString *openUrl = [valueDic ks_stringValueForKey:@"url"];
|
|
|
+ bool can = [[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:openUrl]];
|
|
|
+ if(can){
|
|
|
+ [[UIApplication sharedApplication] openURL:[NSURL URLWithString:openUrl] options:@{} completionHandler:nil];
|
|
|
+ }
|
|
|
}
|
|
|
else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"shareTripartite"]) { // 分享到微信
|
|
|
[self shareToWeChat:parm];
|
|
@@ -639,12 +619,36 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
ctrl.modalPresentationStyle = UIModalPresentationFullScreen;
|
|
|
[self.navigationController presentViewController:ctrl animated:YES completion:nil];
|
|
|
}
|
|
|
+ else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"paymentOrder"]) {
|
|
|
+ NSDictionary *content = [parm ks_dictionaryValueForKey:@"content"];
|
|
|
+ NSString *channel = [content ks_stringValueForKey:@"payChannel"];
|
|
|
+ if ([channel isEqualToString:@"ali_app"]) {
|
|
|
+ NSString *infoMessage = [content ks_stringValueForKey:@"payInfo"];
|
|
|
+ [KSOrderManager dealWithAliSDK:infoMessage];
|
|
|
+ }
|
|
|
+ else if ([channel isEqualToString:@"wx_app"]) {
|
|
|
+ NSString *infoMessage = [content ks_stringValueForKey:@"payInfo"];
|
|
|
+ [KSOrderManager dealWithWXSDK:infoMessage];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"joinLiveRoom"]) { // 进入直播间
|
|
|
+ NSDictionary *valueDic = [parm ks_dictionaryValueForKey:@"content"];
|
|
|
+ NSString *roomId = [valueDic ks_stringValueForKey:@"roomId"];
|
|
|
+ [LOADING_MANAGER showHUD];
|
|
|
+ [KSEnterLiveroomManager joinLiveWithRoomId:roomId inController:(CustomNavViewController *)self.navigationController callback:^{
|
|
|
+ [LOADING_MANAGER removeHUD];
|
|
|
+ }];
|
|
|
+ }
|
|
|
+ else if ([[parm ks_stringValueForKey:@"api"] isEqualToString:@"setEventTracking"]) {
|
|
|
+ NSString *type = [[parm ks_dictionaryValueForKey:@"content"] ks_stringValueForKey:@"type"];
|
|
|
+ [USER_MANAGER sendUMEvent:type];
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- (void)videCropImage:(UIImage *)cover content:(NSDictionary *)content {
|
|
|
NSData *imgData = [UIImage turnsImaegDataByImage:cover];
|
|
|
NSString *fileName = @"videoCoverImage";
|
|
|
-
|
|
|
+
|
|
|
[LOADING_MANAGER showCustomLoading:@"上传中..."];
|
|
|
[UPLOAD_MANAGER configBucketName:@"klx"];
|
|
|
[UPLOAD_MANAGER uploadFile:imgData fileName:fileName fileSuffix:[UIImage typeForImageData:imgData] progress:^(int64_t bytesWritten, int64_t totalBytes) {
|
|
@@ -1050,14 +1054,18 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
|
|
|
- (void)webView:(WKWebView *)webView didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential *_Nullable))completionHandler
|
|
|
{
|
|
|
- if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) {
|
|
|
- if (challenge.previousFailureCount == 0) {
|
|
|
- NSURLCredential *credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust];
|
|
|
- completionHandler(NSURLSessionAuthChallengeUseCredential, credential);
|
|
|
- } else {
|
|
|
- completionHandler(NSURLSessionAuthChallengeCancelAuthenticationChallenge, nil);
|
|
|
+
|
|
|
+ dispatch_queue_t queue = dispatch_queue_create("webViewChallengeQueue", NULL);
|
|
|
+ dispatch_async(queue, ^{
|
|
|
+ if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) {
|
|
|
+ if (challenge.previousFailureCount == 0) {
|
|
|
+ NSURLCredential *credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust];
|
|
|
+ completionHandler(NSURLSessionAuthChallengeUseCredential, credential);
|
|
|
+ } else {
|
|
|
+ completionHandler(NSURLSessionAuthChallengeCancelAuthenticationChallenge, nil);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
//当因为某些问题,导致webView进程终止时触发
|
|
@@ -1186,8 +1194,9 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
|
|
|
- (void)dealloc {
|
|
|
NSLog(@"webView dealloc -----");
|
|
|
- [[_myWebView configuration].userContentController removeScriptMessageHandlerForName:@"COLEXIU"];
|
|
|
+ [[_myWebView configuration].userContentController removeScriptMessageHandlerForName:SCRIPT_NAME];
|
|
|
[_myWebView removeObserver:self forKeyPath:@"estimatedProgress"];
|
|
|
+ [_myWebView removeObserver:self forKeyPath:@"title"];
|
|
|
[_myWebView loadHTMLString:@"" baseURL:nil];
|
|
|
[_myWebView removeFromSuperview];
|
|
|
_myWebView = nil;
|
|
@@ -1412,37 +1421,6 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
return filesize;
|
|
|
}
|
|
|
|
|
|
-- (KSWebLoadRefreshView *)errorView {
|
|
|
- if (!_errorView) {
|
|
|
- _errorView = [KSWebLoadRefreshView shareInstance];
|
|
|
- MJWeakSelf;
|
|
|
- [_errorView failViewActionCallback:^(BOOL isBack) {
|
|
|
- [weakSelf hideErrorView];
|
|
|
- if (isBack) {
|
|
|
- [weakSelf backAction];
|
|
|
- }
|
|
|
- else {
|
|
|
- [weakSelf loadRequest];
|
|
|
- }
|
|
|
- }];
|
|
|
- }
|
|
|
- return _errorView;
|
|
|
-}
|
|
|
-
|
|
|
-- (void)showErrorView {
|
|
|
- if (![self.view.subviews containsObject:self.errorView]) {
|
|
|
- [self.view addSubview:self.errorView];
|
|
|
- [self.errorView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.left.right.top.bottom.mas_equalTo(self.view);
|
|
|
- }];
|
|
|
- [self.view bringSubviewToFront:self.errorView];
|
|
|
- }
|
|
|
-}
|
|
|
-- (void)hideErrorView {
|
|
|
- if ([self.view.subviews containsObject:self.errorView]) {
|
|
|
- [self.errorView removeFromSuperview];
|
|
|
- }
|
|
|
-}
|
|
|
|
|
|
#pragma mark - UIDocumentInteractionControllerDelegate
|
|
|
-(UIViewController*)documentInteractionControllerViewControllerForPreview:(UIDocumentInteractionController*)controller{
|
|
@@ -1528,6 +1506,68 @@ typedef NS_ENUM(NSInteger, CHOOSETYPE) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+#pragma mark ---- 镜像和投屏检测
|
|
|
+
|
|
|
+- (void)captureViewTips:(NSNotification *)notification {
|
|
|
+ [self checkCaptured];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)checkCaptured {
|
|
|
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
+ if ([self checkIsCaptured]) {
|
|
|
+ [self didCapturedView];
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
+- (BOOL)checkIsCaptured {
|
|
|
+ if ([UIScreen mainScreen].isCaptured && [UIScreen screens].count < 2) {
|
|
|
+ return YES;
|
|
|
+ }
|
|
|
+ return NO;
|
|
|
+}
|
|
|
+
|
|
|
+- (void)didCapturedView {
|
|
|
+
|
|
|
+ NSMutableDictionary *sendParm = [NSMutableDictionary dictionary];
|
|
|
+ [sendParm setValue:@"setVideoPlayer" forKey:@"api"];
|
|
|
+ NSMutableDictionary *content = [NSMutableDictionary dictionary];
|
|
|
+ [content setValue:@"pause" forKey:@"status"];
|
|
|
+ [sendParm setValue:content forKey:@"content"];
|
|
|
+ [self postMessage:sendParm];
|
|
|
+}
|
|
|
+
|
|
|
+- (KSWebLoadRefreshView *)errorView {
|
|
|
+ if (!_errorView) {
|
|
|
+ _errorView = [KSWebLoadRefreshView shareInstance];
|
|
|
+ MJWeakSelf;
|
|
|
+ [_errorView failViewActionCallback:^(BOOL isBack) {
|
|
|
+ [weakSelf hideErrorView];
|
|
|
+ if (isBack) {
|
|
|
+ [weakSelf backAction];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ [weakSelf loadRequest];
|
|
|
+ }
|
|
|
+ }];
|
|
|
+ }
|
|
|
+ return _errorView;
|
|
|
+}
|
|
|
+
|
|
|
+- (void)showErrorView {
|
|
|
+ if (![self.view.subviews containsObject:self.errorView]) {
|
|
|
+ [self.view addSubview:self.errorView];
|
|
|
+ [self.errorView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.left.right.top.bottom.mas_equalTo(self.view);
|
|
|
+ }];
|
|
|
+ [self.view bringSubviewToFront:self.errorView];
|
|
|
+ }
|
|
|
+}
|
|
|
+- (void)hideErrorView {
|
|
|
+ if ([self.view.subviews containsObject:self.errorView]) {
|
|
|
+ [self.errorView removeFromSuperview];
|
|
|
+ }
|
|
|
+}
|
|
|
/*
|
|
|
#pragma mark - Navigation
|
|
|
|