Commit 2e3d6597 authored by Mazy's avatar Mazy

fix bugs

parent dd37ed05
...@@ -70,6 +70,13 @@ ...@@ -70,6 +70,13 @@
ReferencedContainer = "container:GYDemo.xcodeproj"> ReferencedContainer = "container:GYDemo.xcodeproj">
</BuildableReference> </BuildableReference>
</BuildableProductRunnable> </BuildableProductRunnable>
<EnvironmentVariables>
<EnvironmentVariable
key = "OS_ACTIVITY_MODE"
value = "disable"
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
</LaunchAction> </LaunchAction>
<ProfileAction <ProfileAction
buildConfiguration = "Release" buildConfiguration = "Release"
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<key>GYDemo.xcscheme_^#shared#^_</key> <key>GYDemo.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>7</integer> <integer>5</integer>
</dict> </dict>
</dict> </dict>
</dict> </dict>
......
...@@ -26,5 +26,10 @@ ...@@ -26,5 +26,10 @@
- (void)ios_getOrderData; - (void)ios_getOrderData;
- (void)unityVideo:(BOOL)video; - (void)unityVideo:(BOOL)video;
// 获取当前window
- (UIWindow *)getMainWindow;
// 获取当前window 最上方控制器
- (UIViewController *)getTopViewController;
@end @end
...@@ -688,6 +688,31 @@ NSDictionary* appLaunchOpts; ...@@ -688,6 +688,31 @@ NSDictionary* appLaunchOpts;
NSLog(@"---"); NSLog(@"---");
} }
- (UIWindow *)getMainWindow {
return [[self ufw] appController].window;
}
- (UIViewController *)getTopViewController {
UIViewController *resultVC;
//这里的window有时取得不是delegate的window
resultVC = [self _topViewController:[[self getMainWindow] rootViewController]];
while (resultVC.presentedViewController) {
resultVC = [self _topViewController: resultVC.presentedViewController];
}
return resultVC;
}
- (UIViewController *)_topViewController:(UIViewController *)vc {
if ([vc isKindOfClass:[UINavigationController class]]) {
return [self _topViewController:[(UINavigationController *)vc topViewController]];
} else if ([vc isKindOfClass:[UITabBarController class]]) {
return [self _topViewController:[(UITabBarController *)vc selectedViewController]];
} else {
return vc;
}
return nil;
}
@end @end
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#import "GYAdsManager+OpenScreen.h" #import "GYAdsManager+OpenScreen.h"
#import "GYAdsManager+Flow.h" #import "GYAdsManager+Flow.h"
#import "GYAdsManager+RewardedVideo.h" #import "GYAdsManager+RewardedVideo.h"
#import "AppDelegate.h"
static GYAdsManager * manager; static GYAdsManager * manager;
@implementation GYAdsManager @implementation GYAdsManager
...@@ -24,7 +25,8 @@ static GYAdsManager * manager; ...@@ -24,7 +25,8 @@ static GYAdsManager * manager;
- (instancetype)init{ - (instancetype)init{
if (self = [super init]) { if (self = [super init]) {
self.mainWindow = [(AppDelegate *)[UIApplication sharedApplication].delegate getMainWindow];
self.currentVC = [(AppDelegate *)[UIApplication sharedApplication].delegate getTopViewController];
} }
return self; return self;
} }
......
...@@ -55,6 +55,8 @@ ...@@ -55,6 +55,8 @@
} else { } else {
// Fallback on earlier versions // Fallback on earlier versions
} }
[webViewConfig.userContentController addScriptMessageHandler:self name:@"eventUtils"];
[webViewConfig.userContentController addScriptMessageHandler:self name:@"closeView"];
[webViewConfig.userContentController addScriptMessageHandler:self name:@"backTrack"]; [webViewConfig.userContentController addScriptMessageHandler:self name:@"backTrack"];
[webViewConfig.userContentController addScriptMessageHandler:self name:@"settingCallBack"]; [webViewConfig.userContentController addScriptMessageHandler:self name:@"settingCallBack"];
[webViewConfig.userContentController addScriptMessageHandler:self name:@"withDraw"]; [webViewConfig.userContentController addScriptMessageHandler:self name:@"withDraw"];
...@@ -343,6 +345,15 @@ ...@@ -343,6 +345,15 @@
"script.content=\"width=device-width, initial-scale=1.0,maximum-scale=1.0, minimum-scale=1.0, user-scalable=no\";" "script.content=\"width=device-width, initial-scale=1.0,maximum-scale=1.0, minimum-scale=1.0, user-scalable=no\";"
"document.getElementsByTagName('head')[0].appendChild(script);"; "document.getElementsByTagName('head')[0].appendChild(script);";
[webView evaluateJavaScript:injectionJSString completionHandler:nil]; [webView evaluateJavaScript:injectionJSString completionHandler:nil];
NSString* method = [NSString stringWithFormat:@"getStatusBarHeight(\"%.0f\")", UIApplication.sharedApplication.statusBarFrame.size.height / 2 + 22];
[webView evaluateJavaScript:method completionHandler:^(id _Nullable obj, NSError * _Nullable error) {
if (error) {
NSLog(@"%@", error);
} else {
NSLog(@"getStatusBarHeight JS方法调用成功");
}
}];
} }
//加载失败 //加载失败
...@@ -434,7 +445,7 @@ ...@@ -434,7 +445,7 @@
- (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message { - (void)userContentController:(WKUserContentController *)userContentController didReceiveScriptMessage:(WKScriptMessage *)message {
NSLog(@"%@",message.name);// 方法名 NSLog(@"%@",message.name);// 方法名
__weak typeof(self) weakSelf = self; __weak typeof(self) weakSelf = self;
if([message.name isEqualToString:@"backTrack"]){ if([message.name isEqualToString:@"backTrack"] || [message.name isEqualToString:@"closeView"]){
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[weakSelf goBackController]; [weakSelf goBackController];
}); });
...@@ -497,7 +508,7 @@ ...@@ -497,7 +508,7 @@
[self.webView reload]; [self.webView reload];
}; };
}else if([message.name isEqualToString:@"jumpWebActivity"]){ } else if([message.name isEqualToString:@"jumpWebActivity"]){
NSString * bodyStr = message.body; NSString * bodyStr = message.body;
NSData * data = [bodyStr dataUsingEncoding: NSUTF8StringEncoding]; NSData * data = [bodyStr dataUsingEncoding: NSUTF8StringEncoding];
NSDictionary * dict = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil]; NSDictionary * dict = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:nil];
...@@ -513,6 +524,13 @@ ...@@ -513,6 +524,13 @@
UINavigationController * nav = [[UINavigationController alloc] initWithRootViewController:web]; UINavigationController * nav = [[UINavigationController alloc] initWithRootViewController:web];
nav.modalPresentationStyle = UIModalPresentationFullScreen; nav.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentViewController:nav animated:YES completion:nil]; [self presentViewController:nav animated:YES completion:nil];
} else if([message.name isEqualToString:@"eventUtils"]){ //上报
NSString * bodyStr = message.body;
if (bodyStr) {
[[CGUserManager shared] addLocCollection:bodyStr value:@""];
}
} }
} }
......
...@@ -14,12 +14,17 @@ ...@@ -14,12 +14,17 @@
<key>Bytedance-UnionAD.xcscheme_^#shared#^_</key> <key>Bytedance-UnionAD.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>6</integer> <integer>12</integer>
</dict>
<key>GDTMobSDK.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>11</integer>
</dict> </dict>
<key>KSAdSDK.xcscheme_^#shared#^_</key> <key>KSAdSDK.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>9</integer> <integer>7</integer>
</dict> </dict>
<key>MBProgressHUD.xcscheme</key> <key>MBProgressHUD.xcscheme</key>
<dict> <dict>
...@@ -57,7 +62,7 @@ ...@@ -57,7 +62,7 @@
<key>WechatOpenSDK.xcscheme_^#shared#^_</key> <key>WechatOpenSDK.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>5</integer> <integer>9</integer>
</dict> </dict>
</dict> </dict>
<key>SuppressBuildableAutocreation</key> <key>SuppressBuildableAutocreation</key>
......
...@@ -7,12 +7,12 @@ ...@@ -7,12 +7,12 @@
<key>Unity-iPhone.xcscheme_^#shared#^_</key> <key>Unity-iPhone.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>10</integer> <integer>6</integer>
</dict> </dict>
<key>UnityFramework.xcscheme_^#shared#^_</key> <key>UnityFramework.xcscheme_^#shared#^_</key>
<dict> <dict>
<key>orderHint</key> <key>orderHint</key>
<integer>11</integer> <integer>10</integer>
</dict> </dict>
</dict> </dict>
</dict> </dict>
......
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