Channel/IOS/gtios/Plugins/The2thWorldSDK/UniversalSDK.h | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
Channel/IOS/gtios/Plugins/The2thWorldSDK/UniversalSDK.mm | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
Channel/IOS/qkbt2game/Plugins/The2thWorldSDK/UniversalSDK.h | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
Channel/IOS/qkbt2game/Plugins/The2thWorldSDK/UniversalSDK.mm | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
Channel/IOS/gtios/Plugins/The2thWorldSDK/UniversalSDK.h
@@ -10,6 +10,8 @@ #import <Foundation/Foundation.h> #import <UIKit/UIKit.h> #import <WebKit/WebKit.h> #define UNITY_OBJ_NAME "SDKUtility" #define UNITY_FUNC_NAME "HandleSdkMessage" @@ -68,8 +70,9 @@ static BOOL JPush_IsProduction = FALSE; @interface UniversalSDK : NSObject { UIWebView* m_UIWebView; @interface UniversalSDK : NSObject<WKUIDelegate, WKNavigationDelegate> { WKWebView* m_UIWebView; WKWebView* m_fakeUIWebView; UIButton* m_CloseBtn; } Channel/IOS/gtios/Plugins/The2thWorldSDK/UniversalSDK.mm
@@ -14,8 +14,7 @@ #import "SystemConfiguration/CaptiveNetwork.h" #import <YYJPlatform/YYJPlatform.h> @interface UniversalSDK()<UIWebViewDelegate> @end @implementation UniversalSDK @@ -36,6 +35,19 @@ static NSString * const kClientID = @"468442318367-ocoqrm0kei0gpkrnnq1ql628v4g4dbqd.apps.googleusercontent.com"; -(id)init { self = [super init]; m_fakeUIWebView = [[WKWebView alloc] initWithFrame:CGRectZero]; NSURL *url = [NSURL URLWithString:@"www.baidu.com"]; NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:10.f]; [m_fakeUIWebView loadRequest:request]; return self; } -(void) Init { UIDevice *_device = [UIDevice currentDevice]; @@ -62,18 +74,21 @@ [[NSUserDefaults standardUserDefaults] setObject:_uniqueID forKey:@"tsw_unique_id"]; [[NSUserDefaults standardUserDefaults] synchronize]; } // 取得UserAgent UIWebView* _webView = [[UIWebView alloc] initWithFrame:CGRectZero]; NSString* _userAgent = [_webView stringByEvaluatingJavaScriptFromString:@"navigator.userAgent"]; [m_fakeUIWebView evaluateJavaScript:@"navigator.userAgent" completionHandler:^(id _Nullable userAgent, NSError * _Nullable error) { NSLog(@"%@", userAgent); NSString* _userAgent = [NSString stringWithFormat:@"%@", userAgent]; // 发送设备信息 NSMutableDictionary *_dict = [NSMutableDictionary dictionaryWithObjectsAndKeys: _uniqueID,@"unique_id", _idfa,@"android_id", [NSNumber numberWithInt:S2U_DeviceInfo],@"code", _userAgent,@"userAgent",nil]; [self SendMessageToUnity:_dict]; }]; // 发送设备信息 NSMutableDictionary *_dict = [NSMutableDictionary dictionaryWithObjectsAndKeys: _uniqueID,@"unique_id", _idfa,@"android_id", [NSNumber numberWithInt:S2U_DeviceInfo],@"code", _userAgent,@"userAgent",nil]; [self SendMessageToUnity:_dict]; } -(void)SendMessageToUnity:(NSDictionary*)dict @@ -133,13 +148,15 @@ float _offsetX = (_bounds.size.width - _width) * .5f; float _offsetY = (_bounds.size.height - _height) * .5f; m_UIWebView = [[UIWebView alloc] initWithFrame:CGRectMake(_offsetX, _offsetY, _width, _height)]; m_UIWebView.delegate = self; m_UIWebView.scalesPageToFit = YES ; m_UIWebView = [[WKWebView alloc] initWithFrame:CGRectMake(_offsetX, _offsetY, _width, _height)]; m_UIWebView.UIDelegate = self; m_UIWebView.navigationDelegate = self ; m_UIWebView.scrollView.scrollEnabled = YES; m_UIWebView.scrollView.bounces = NO; NSURLRequest *request =[NSURLRequest requestWithURL:[NSURL URLWithString:url]]; [m_UIWebView loadRequest:request]; } -(void) btnClick:(UIButton*)sender { @@ -156,12 +173,10 @@ m_UIWebView = NULL; } -(void)webViewDidStartLoad:(UIWebView *)webView{ } -(void)webViewDidFinishLoad:(UIWebView *)webView{ //-(void)webViewDidFinishLoad:(WKWebView *)webView{ - (void)webView:(WKWebView *)webView didFinishNavigation:(null_unspecified WKNavigation *)navigation{ [UnityGetMainWindow().rootViewController.view addSubview:m_UIWebView]; CGRect _bounds = UnityGetMainWindow().bounds; float _scale = _bounds.size.width / 1334; @@ -182,10 +197,11 @@ [m_CloseBtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside]; [m_UIWebView addSubview:m_CloseBtn]; UIView *view = UnityGetGLViewController().view; [view addSubview:m_UIWebView]; } -(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{ } -(void)QuickSDKInit:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { Channel/IOS/qkbt2game/Plugins/The2thWorldSDK/UniversalSDK.h
@@ -10,6 +10,7 @@ #import <Foundation/Foundation.h> #import <UIKit/UIKit.h> #import <WebKit/WebKit.h> #define UNITY_OBJ_NAME "SDKUtility" #define UNITY_FUNC_NAME "HandleSdkMessage" @@ -60,8 +61,9 @@ static BOOL JPush_IsProduction = FALSE; @interface UniversalSDK : NSObject { UIWebView* m_UIWebView; @interface UniversalSDK : NSObject<WKUIDelegate, WKNavigationDelegate> { WKWebView* m_UIWebView; WKWebView* m_fakeUIWebView; UIButton* m_CloseBtn; } Channel/IOS/qkbt2game/Plugins/The2thWorldSDK/UniversalSDK.mm
@@ -14,9 +14,6 @@ #import "SystemConfiguration/CaptiveNetwork.h" #import <SMPCQuickSDK/SMPCQuickSDK.h> @interface UniversalSDK()<UIWebViewDelegate> @end @implementation UniversalSDK #define CHANNEL_NUM 1 @@ -31,6 +28,20 @@ static NSString* sGameID; static NSString* sUserName; static NSThread* _thread; -(id)init { self = [super init]; m_fakeUIWebView = [[WKWebView alloc] initWithFrame:CGRectZero]; NSURL *url = [NSURL URLWithString:@"www.baidu.com"]; NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:10.f]; [m_fakeUIWebView loadRequest:request]; return self; } -(void) Init { @@ -60,16 +71,18 @@ } // 取得UserAgent UIWebView* _webView = [[UIWebView alloc] initWithFrame:CGRectZero]; NSString* _userAgent = [_webView stringByEvaluatingJavaScriptFromString:@"navigator.userAgent"]; // 发送设备信息 NSMutableDictionary *_dict = [NSMutableDictionary dictionaryWithObjectsAndKeys: _uniqueID,@"unique_id", _idfa,@"android_id", [NSNumber numberWithInt:S2U_DeviceInfo],@"code", _userAgent,@"userAgent",nil]; [self SendMessageToUnity:_dict]; [m_fakeUIWebView evaluateJavaScript:@"navigator.userAgent" completionHandler:^(id _Nullable userAgent, NSError * _Nullable error) { NSLog(@"%@", userAgent); NSString* _userAgent = [NSString stringWithFormat:@"%@", userAgent]; // 发送设备信息 NSMutableDictionary *_dict = [NSMutableDictionary dictionaryWithObjectsAndKeys: _uniqueID,@"unique_id", _idfa,@"android_id", [NSNumber numberWithInt:S2U_DeviceInfo],@"code", _userAgent,@"userAgent",nil]; [self SendMessageToUnity:_dict]; }]; } -(void)SendMessageToUnity:(NSDictionary*)dict @@ -129,13 +142,15 @@ float _offsetX = (_bounds.size.width - _width) * .5f; float _offsetY = (_bounds.size.height - _height) * .5f; m_UIWebView = [[UIWebView alloc] initWithFrame:CGRectMake(_offsetX, _offsetY, _width, _height)]; m_UIWebView.delegate = self; m_UIWebView.scalesPageToFit = YES ; m_UIWebView = [[WKWebView alloc] initWithFrame:CGRectMake(_offsetX, _offsetY, _width, _height)]; m_UIWebView.UIDelegate = self; m_UIWebView.navigationDelegate = self ; m_UIWebView.scrollView.scrollEnabled = YES; m_UIWebView.scrollView.bounces = NO; NSURLRequest *request =[NSURLRequest requestWithURL:[NSURL URLWithString:url]]; [m_UIWebView loadRequest:request]; } -(void) btnClick:(UIButton*)sender { @@ -152,12 +167,10 @@ m_UIWebView = NULL; } -(void)webViewDidStartLoad:(UIWebView *)webView{ } -(void)webViewDidFinishLoad:(UIWebView *)webView{ //-(void)webViewDidFinishLoad:(WKWebView *)webView{ - (void)webView:(WKWebView *)webView didFinishNavigation:(null_unspecified WKNavigation *)navigation{ [UnityGetMainWindow().rootViewController.view addSubview:m_UIWebView]; CGRect _bounds = UnityGetMainWindow().bounds; float _scale = _bounds.size.width / 1334; @@ -166,7 +179,7 @@ float _height = 560 * _scale; m_CloseBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [m_CloseBtn setFrame:CGRectMake(_width - 455 * _scale, _height - 86 * _scale, 180 * _scale, 72 * _scale)]; [m_CloseBtn setFrame:CGRectMake(_width - 600 * _scale, _height - 86 * _scale, 360 * _scale, 72 * _scale)]; [m_CloseBtn setTitle:@"我知道了" forState:UIControlStateNormal]; NSString *_bundlePath = [[NSBundle mainBundle] pathForResource:@"The2thWorldRES.bundle" ofType:nil]; @@ -178,9 +191,9 @@ [m_CloseBtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside]; [m_UIWebView addSubview:m_CloseBtn]; } -(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{ UIView *view = UnityGetGLViewController().view; [view addSubview:m_UIWebView]; } -(void)QuickSDKInit:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { @@ -535,7 +548,7 @@ frame += s_frameSize; rbytes += length + sizeof(char); len -= s_frameSize; totalSize += length; totalSize += (length+1); } opus_encoder_destroy(enc); return totalSize;