allez
2021-08-12 471d95a66fd642b75f788e8b50730e9d95ef8e2e
Channel/IOS/gtios/Plugins/The2thWorldSDK/UniversalSDK.mm
@@ -12,7 +12,7 @@
#import <UserNotifications/UserNotifications.h>
#endif
#import "SystemConfiguration/CaptiveNetwork.h"
#import <YYJPlatform/YYJPlatform.h>
#import <GMSDK/GMSDK.h>
#import <AppTrackingTransparency/AppTrackingTransparency.h>
@@ -210,26 +210,26 @@
     该通知应注册在初始化之前
     */
    //添加一个初始化通知观察者,初始化结束后,登录等操作务必在收到该通知后调用
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(YYJPlatformInitFinished) name:yyj_PlatformInitDidFinishedNotification object:nil];
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(YYJPlatformInitFinished) name:PlatformInitDidFinishedNotification object:nil];
    
    //初始化失败
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(YYJPlatformInitFinishedFail)
    name:yyj_PlatformInitFinishedFailNotification object:nil];
    name:PlatformInitFinishedFailNotification object:nil];
    
    // 添加一个支付成功通知观察者
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(YYJPlatformBMaiSuccessful) name:yyj_PlatformBMaiSuccessfulNotification object:nil];
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(YYJPlatformBMaiSuccessful) name:PlatformBMaiSuccessfulNotification  object:nil];
    
    // 添加一个支付失败通知观察者
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(YYJPlatformBMaiFail) name:yyj_PlatformBMaiFailNotification object:nil];
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(YYJPlatformBMaiFail) name:PlatformBMaiFailNotification  object:nil];
    
    //添加一个登录成功通知观察者,调用悬浮框等操作务必在收到该通知后调用
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(YYJPlatformLogin) name:yyj_PlatformLoginNotification object:nil];
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(YYJPlatformLogin) name:PlatformLoginNotification object:nil];
    
    //添加一个注销成功通知观察者
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(YYJPlatformLogout) name:yyj_PlatformLogoutNotification object:nil];
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(YYJPlatformLogout) name:PlatformLogoutNotification  object:nil];
    
   //添加FB分享 结果通知观察者
   [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(YYJPlatformFBShareNotify:) name:yyj_PlatformShareFBNotification object:nil];
   [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(YYJPlatformFBShareNotify:) name:PlatformShareFBNotification  object:nil];
    
#ifdef DEBUG
    // 输出日志
@@ -239,11 +239,11 @@
    [self initYYJSdk];
    
    //appsflyer
    [[YYJPlatform yyj_defaultPlatform] yyj_AppsFlyer_Init:AF_KEY appleAppID:AF_APPLE_APPID];
    [[SXGMSDK shareSDK] AppsFlyer_Init:AF_KEY appleAppID:AF_APPLE_APPID];
    //google
    [[YYJPlatform yyj_defaultPlatform] yyj_google_Init:kClientID];
    [[SXGMSDK shareSDK] google_Init:kClientID];
    //facebook
    [[YYJPlatform yyj_defaultPlatform] yyj_fb_Init:application launchOptions:launchOptions];
    [[SXGMSDK shareSDK] fb_Init:application launchOptions:launchOptions];
    
    
    //升级iOS SDK V6 介绍 ++++++++
@@ -255,13 +255,13 @@
    
}
-(void)sendAppsFlyerLaunch:(UIApplication *)application {
    [[YYJPlatform yyj_defaultPlatform] yyj_AppFlysStart];
    [[SXGMSDK shareSDK] AppFlysStart];
}
-(void) initYYJSdk{
    NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
    NSString *app_Version = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
    // SDK初始化,务必放在其他接⼝调⽤之前
    [[YYJPlatform yyj_defaultPlatform]yyj_initializeWithAppId: YYJ_APPID gameVersion:app_Version appScheme: YYJ_APPSCHEME];
    [[SXGMSDK shareSDK] initializeWithAppId:YYJ_APPID gameVersion:app_Version];
    initedState=0;
}
@@ -281,18 +281,20 @@
}
- (void)YYJPlatformLogin {
    NSString *regType = [[YYJPlatform yyj_defaultPlatform] yyj_regType];
    if(regType&&[regType length]!=0){
        NSLog(@"渠道注册成功");
        NSDictionary *_dict = [NSDictionary dictionaryWithObjectsAndKeys:
                               regType, @"reg_type",
                               [NSNumber numberWithInt:S2U_FreePlatformRegisterOk], @"code", nil];
        [self SendMessageToUnity:_dict];
    }else{
//    NSString *regType = [[SXGMSDK shareSDK] regType];
    NSString *loginType = [[SXGMSDK shareSDK] loginType];
//    if(regType&&[regType length]!=0){
//        NSLog(@"渠道注册成功");
//        NSDictionary *_dict = [NSDictionary dictionaryWithObjectsAndKeys:
//                               regType, @"reg_type",
//                               [NSNumber numberWithInt:S2U_FreePlatformRegisterOk], @"code", nil];
//        [self SendMessageToUnity:_dict];
//    }
    if(loginType&&[loginType length]!=0){
        NSLog(@"渠道登录成功");
        NSString *account = [[YYJPlatform yyj_defaultPlatform] yyj_userUID];
        NSString *game_id = [[YYJPlatform yyj_defaultPlatform] yyj_gameId];
        NSString *session_id = [[YYJPlatform yyj_defaultPlatform] yyj_token];
        NSString *account = [[SXGMSDK shareSDK] userUID];
        NSString *game_id = [[SXGMSDK shareSDK] gameId];
        NSString *session_id = [[SXGMSDK shareSDK] token];
        
        NSDictionary *_dict = [NSDictionary dictionaryWithObjectsAndKeys:
                               [NSDictionary dictionaryWithObjectsAndKeys:account, @"account",
@@ -301,7 +303,9 @@
                               [NSNumber numberWithInt:S2U_FreePlatformLoginOk], @"code", nil];
        [self SendMessageToUnity:_dict];
    }
    [[YYJPlatform yyj_defaultPlatform]yyj_showFloatWindow]; //显示悬浮窗
    //调用悬浮框,开发者继续游戏逻辑
    [[SXGMSDK shareSDK] showFloatWindow];
    
    //升级iOS SDK V6 介绍 ++++++++
    if (@available(iOS 14, *)) {
@@ -336,6 +340,7 @@
{
    NSString *msg = obj?[obj.userInfo valueForKey:@"msg"]: @"";
    NSInteger code = obj? [[obj.userInfo valueForKey:@"code"] intValue] :-1;
    //code: 1成功, -1 取消, -2 异常
    int state = 0;
    switch (code) {
@@ -384,7 +389,8 @@
        }
            break;
        case 1:
            [[YYJPlatform yyj_defaultPlatform]yyj_userLogin];
            //[[YYJPlatform yyj_defaultPlatform]yyj_userLogin];
            [[SXGMSDK shareSDK] UserLogin];
            break;
        case 2:
            [self initYYJSdk];
@@ -426,46 +432,54 @@
        case U2S_FreePlatformLogin:
            [self PlatformLogin];
            break;
        case U2S_ShowAccountView:
        {
            [[SXGMSDK shareSDK] ShowAccountView];
        }
            break;
        case U2S_FreePlatformLogout:
        {
            [[YYJPlatform yyj_defaultPlatform]yyj_userLogout];
            [[SXGMSDK shareSDK] UserLogin];
        }
            break;
        case U2S_CreateRole:
        {
            // 更新角色信息
            NSString *serverName = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"serverName"]];
            NSString *gameRoleName = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"roleName"]];
            NSString *serverId = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"sid"]];
            NSString *serviceTypeId= @"0";
            NSString *serverName = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"serverName"]];
            NSString *gameRoleID = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"roleID"]];
            NSString *gameRoleName = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"roleName"]];
            NSString *gameUserLevel = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"level"]];
            
            [[YYJPlatform yyj_defaultPlatform]yyj_submitRoleInfoWithServerid:serverId andServerName:serverName andCharid:gameRoleID andRoleName:gameRoleName andRolelevel:gameUserLevel];
            [[SXGMSDK shareSDK]submitRoleInfoWithServiceCode:serverId WithRoleId:gameRoleID WithRoleName:gameRoleName WithLevel:gameUserLevel WithServiceTypeId:serviceTypeId WithServiceTypeName:serverName ];
            break;
        }
        case U2S_RoleLogin:
        {
            // 更新角色信息
            NSString *serverName = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"serverName"]];
            NSString *gameRoleName = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"roleName"]];
            NSString *serverId = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"sid"]];
            NSString *serviceTypeId= @"0";
            NSString *serverName = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"serverName"]];
            NSString *gameRoleID = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"roleID"]];
            NSString *gameRoleName = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"roleName"]];
            NSString *gameUserLevel = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"level"]];
            
            [[YYJPlatform yyj_defaultPlatform]yyj_submitRoleInfoWithServerid:serverId andServerName:serverName andCharid:gameRoleID andRoleName:gameRoleName andRolelevel:gameUserLevel];
            [[SXGMSDK shareSDK]submitRoleInfoWithServiceCode:serverId WithRoleId:gameRoleID WithRoleName:gameRoleName WithLevel:gameUserLevel WithServiceTypeId:serviceTypeId WithServiceTypeName:serverName ];
            break;
        }
            
        case U2S_RoleLevelUp:
        {
            // 更新角色信息
            NSString *serverName = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"serverName"]];
            NSString *gameRoleName = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"roleName"]];
            NSString *serverId = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"sid"]];
            NSString *serviceTypeId= @"0";
            NSString *serverName = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"serverName"]];
            NSString *gameRoleID = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"roleID"]];
            NSString *gameRoleName = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"roleName"]];
            NSString *gameUserLevel = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"level"]];
            
            [[YYJPlatform yyj_defaultPlatform]yyj_submitRoleInfoWithServerid:serverId andServerName:serverName andCharid:gameRoleID andRoleName:gameRoleName andRolelevel:gameUserLevel];
            [[SXGMSDK shareSDK]submitRoleInfoWithServiceCode:serverId WithRoleId:gameRoleID WithRoleName:gameRoleName WithLevel:gameUserLevel WithServiceTypeId:serviceTypeId WithServiceTypeName:serverName ];
            break;
        }
        case U2S_FreePlatformPay:
@@ -476,13 +490,14 @@
            NSString *productName = [NSString stringWithFormat:@"%@", [_dict objectForKey:@"title"]];
            NSString *mount = [NSString stringWithFormat:@"%@", [_dict objectForKey:@"mount"]];
            NSString *orderId = [NSString stringWithFormat:@"%@", [_dict objectForKey:@"orderId"]];
            NSString *payType = @"apple";
            NSString *_appid = sAppID;
            NSString *extrasParams = [NSString stringWithFormat:@"{\"appid\":\"%@\",\"cpinfo\":\"%@\",\"cporderid\":\"%@\"}",
                                  _appid,
                                  [_dict objectForKey:@"cpInfo"],
                                  [_dict objectForKey:@"orderId"]
                                  ];
            [[YYJPlatform yyj_defaultPlatform] yyj_BMaiWithMoney:mount productID:goodsID productName:productName charId:gameRoleID serverId:serverId expandInfo:extrasParams cporderId:orderId];
            [[SXGMSDK shareSDK] CreatOrderWithCpOrderId:orderId WithMoney:mount WithGoodsId:goodsID WithGoodsName:productName WithPayType:payType WithServer:serverId WithRole:gameRoleID  WithExt:extrasParams];
            break;
        }
        case U2S_BatteryListenStart:
@@ -502,14 +517,15 @@
        {
            NSString *eventName = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"eventName"]];
            NSDictionary *param=  _dict[@"eventValues"];
            [[YYJPlatform yyj_defaultPlatform] yyj_AppFlysTraceEvent:eventName param:param];
            [[SXGMSDK shareSDK] AppFlysTraceEvent:eventName param:param];
            break;
        }
        case U2S_ShareToFaceBook:
        {
            NSString *shareurl = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"url"]];
            [[YYJPlatform yyj_defaultPlatform] yyj_share2facebook:@"share" url:shareurl img:NULL];
            [[SXGMSDK shareSDK] shareByfacebook:@"share" img:NULL];
            break;
        }