liuxue
2021-08-17 20b8c367ac8b3c3ccc735c5694aff22d1689fb20
0000 修正bt3,以master为主
2个文件已修改
77 ■■■■■ 已修改文件
Channel/IOS/qkbt3game/Plugins/The2thWorldSDK/UniversalSDK.h 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Channel/IOS/qkbt3game/Plugins/The2thWorldSDK/UniversalSDK.mm 71 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Channel/IOS/qkbt3game/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/qkbt3game/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 {
@@ -245,8 +258,12 @@
    NSDictionary *userInfo = [notify userInfo];
    if (error == 0) {
        NSString *uid = [[SMPCQuickSDK defaultInstance] userId];
        NSString *cid =[[SMPCQuickSDK defaultInstance] getConfigValue:@"cid"];
        NSString *gameUID = [NSString stringWithFormat:@"%@%@%@", uid,@"@",cid];
        NSString *channel =[[SMPCQuickSDK defaultInstance] getConfigValue:@"channel"];
        NSString *gameUID;
        if(channel&&[channel length]!=0)
            gameUID = [NSString stringWithFormat:@"%@%@%@", uid,@"@",channel];
        else
            gameUID = [NSString stringWithFormat:@"%@@%d", uid, [SMPCQuickSDK defaultInstance].channelType];
        NSString *UserName = [[SMPCQuickSDK defaultInstance] userId];
        //获取user_token,用于从服务器去验证用户信息
        NSString *user_token = userInfo[kSmpcQuickSDKKeyUserToken];
@@ -531,7 +548,7 @@
        frame += s_frameSize;
        rbytes += length + sizeof(char);
        len -= s_frameSize;
        totalSize += length;
        totalSize += (length+1);
    }
    opus_encoder_destroy(enc);
    return totalSize;