allez
2020-09-08 de467e891254f9f80ed83a3ee1c0aea69fd0fb31
0312 quick对接
1个文件已修改
99 ■■■■ 已修改文件
ChannelDiff/iOS/xmyjgame/The2thWorldSDK/UniversalSDK.mm 99 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ChannelDiff/iOS/xmyjgame/The2thWorldSDK/UniversalSDK.mm
@@ -213,9 +213,16 @@
        case SMPC_QUICK_SDK_ERROR_NONE:
        {
            NSLog(@"初始化成功");
            NSString *_appid = [[SMPCQuickSDK defaultInstance] getConfigValue:@"zfappid"];
            if ([_appid isEqualToString:@""])
            {
                _appid = sAppID;
            }
            NSMutableDictionary *_dict = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                          [NSNumber numberWithInt:S2U_SdkInitComplete], @"code",
                                          @"quick", @"channelPlatform",nil];
                                          @"quick", @"channelPlatform",
                                          @"yj_appid", _appid, @"yj_spid", _appid, nil];
            [self SendMessageToUnity:_dict];
        }
            break;
@@ -236,14 +243,15 @@
    NSDictionary *userInfo = [notify userInfo];
    if (error == 0) {
        NSString *uid = [[SMPCQuickSDK defaultInstance] userId];
        sUserName= [[SMPCQuickSDK defaultInstance] userNick];
        NSString *gameUID = [NSString stringWithFormat:@"%@@%d", uid, [SMPCQuickSDK defaultInstance].channelType];
        NSString *UserName = [[SMPCQuickSDK defaultInstance] userNick];
        //获取user_token,用于从服务器去验证用户信息
        NSString *user_token = userInfo[kSmpcQuickSDKKeyUserToken];
        
        NSDictionary *_dict = [NSDictionary dictionaryWithObjectsAndKeys:
                               [NSDictionary dictionaryWithObjectsAndKeys:user_token, @"token",
                                user_token, @"token_expire",
                                sUserName, @"account", nil],@"info",
                                UserName, @"userName",
                                gameUID, @"account", nil],@"info",
                               [NSNumber numberWithInt:S2U_FreePlatformLoginOk], @"code", nil];
        [self SendMessageToUnity:_dict];
    }
@@ -368,6 +376,23 @@
            [[SMPCQuickSDK defaultInstance] logout];
        }
            break;
        case U2S_CreateRole:
        {
            // 更新角色信息
            SMPCQuickSDKGameRoleInfo *gameRoleInfo = [SMPCQuickSDKGameRoleInfo new];
            gameRoleInfo.serverName = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"serverName"]];
            gameRoleInfo.gameRoleName = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"roleName"]];
            gameRoleInfo.serverId = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"sid"]]; //需要是数字字符串
            gameRoleInfo.gameRoleID = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"roleID"]];
            gameRoleInfo.gameUserBalance = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"money"]];
            gameRoleInfo.vipLevel = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"vipLevel"]];
            gameRoleInfo.gameUserLevel = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"level"]];
            gameRoleInfo.partyName = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"familyName"]];
            gameRoleInfo.creatTime = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"createTime"]];
            [[SMPCQuickSDK defaultInstance] updateRoleInfoWith:gameRoleInfo isCreate:YES];//如果这个角色是刚刚创建的,这里isCreate可以传YES
            break;
        }
        case U2S_RoleLogin:
        {
            // 更新角色信息
@@ -376,12 +401,30 @@
            gameRoleInfo.gameRoleName = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"roleName"]];
            gameRoleInfo.serverId = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"sid"]]; //需要是数字字符串
            gameRoleInfo.gameRoleID = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"roleID"]];
            gameRoleInfo.gameUserBalance = @"0";
            gameRoleInfo.gameUserBalance = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"money"]];
            gameRoleInfo.vipLevel = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"vipLevel"]];
            gameRoleInfo.gameUserLevel = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"level"]];
            gameRoleInfo.partyName = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"familyName"]];
            gameRoleInfo.creatTime = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"createTime"]];
            gameRoleInfo.fightPower = @"12345";
            [[SMPCQuickSDK defaultInstance] updateRoleInfoWith:gameRoleInfo isCreate:NO];//如果这个角色是刚刚创建的,这里isCreate可以传YES
            break;
        }
        case U2S_RoleLevelUp:
        {
            // 更新角色信息
            SMPCQuickSDKGameRoleInfo *gameRoleInfo = [SMPCQuickSDKGameRoleInfo new];
            gameRoleInfo.serverName = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"serverName"]];
            gameRoleInfo.gameRoleName = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"roleName"]];
            gameRoleInfo.serverId = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"sid"]]; //需要是数字字符串
            gameRoleInfo.gameRoleID = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"roleID"]];
            gameRoleInfo.gameUserBalance = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"money"]];
            gameRoleInfo.vipLevel = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"vipLevel"]];
            gameRoleInfo.gameUserLevel = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"level"]];
            gameRoleInfo.partyName = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"familyName"]];
            gameRoleInfo.creatTime = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"createTime"]];
            [[SMPCQuickSDK defaultInstance] updateRoleInfoWith:gameRoleInfo isCreate:NO];//如果这个角色是刚刚创建的,这里isCreate可以传YES
            break;
        }
@@ -389,30 +432,38 @@
        {
            SMPCQuickSDKGameRoleInfo *role = [[SMPCQuickSDKGameRoleInfo alloc] init];
            SMPCQuickSDKPayOrderInfo *order = [[SMPCQuickSDKPayOrderInfo alloc] init];
            role.serverName = [NSString stringWithFormat:@"%@", [_dict objectForKey:@"serverName"]]; //必填
            role.gameRoleName = [NSString stringWithFormat:@"%@", [_dict objectForKey:@"roleName"]];//@""
            role.serverId = [NSString stringWithFormat:@"%@", [_dict objectForKey:@"sid"]]; //需要是数字字符串
            role.gameRoleID = [NSString stringWithFormat:@"%@", [_dict objectForKey:@"roleID"]];//
            role.gameUserBalance = @"0";//
            role.vipLevel = [NSString stringWithFormat:@"%@", [_dict objectForKey:@"vipLevel"]];//
            role.gameUserLevel = [NSString stringWithFormat:@"%@", [_dict objectForKey:@"level"]];
            role.partyName = [NSString stringWithFormat:@"%@", [_dict objectForKey:@"familyName"]];//
            role.serverName = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"serverName"]];
            role.gameRoleName = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"roleName"]];
            role.serverId = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"sid"]]; //需要是数字字符串
            role.gameRoleID = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"roleID"]];
            role.gameUserBalance = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"money"]];
            role.vipLevel = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"vipLevel"]];
            role.gameUserLevel = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"level"]];
            role.partyName = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"familyName"]];
            role.creatTime = [NSString stringWithFormat:@"%@",[_dict objectForKey:@"createTime"]];
            order.goodsID = [NSString stringWithFormat:@"%@", [_dict objectForKey:@"cpInfo"]]; //必填 iap时注意和苹果开发者后台一致,或者渠道映射的
            order.productName = [NSString stringWithFormat:@"%@", [_dict objectForKey:@"title"]];//必填
            order.cpOrderID = [NSString stringWithFormat:@"%@", [_dict objectForKey:@"orderId"]]; //必填 游戏订单号
            order.count = 1;  //必填 数量
            order.amount = [[_dict objectForKey:@"mount"] floatValue]; //必填 总价
            order.callbackUrl = @"";
            order.extrasParams = [NSString stringWithFormat:@"{\"appid\":\"%@\",\"cpinfo\":\"%@\",\"cporderid\":\"%@\",\"productid\":\"%@\"}",
                                  sAppID,
                                  [_dict objectForKey:@"cpInfo"],
                                  [_dict objectForKey:@"orderId"],
                                  sGameID];
            //个别渠道要求单价*数量==总价
            if([SMPCQuickSDK defaultInstance].channelType == 9999){
                //通过判断渠道号处理特定渠道的参数
                order.goodsID = @"productlist.name";
            NSString *_appid = [[SMPCQuickSDK defaultInstance] getConfigValue:@"zfappid"];
            if ([_appid isEqualToString:@""])
            {
                _appid = sAppID;
            }
            order.extrasParams = [NSString stringWithFormat:@"{\"appid\":\"%@\",\"cpinfo\":\"%@\",\"cporderid\":\"%@\"}",
                                  _appid,
                                  [_dict objectForKey:@"cpInfo"],
                                  [_dict objectForKey:@"orderId"]
                                  ];
//            //个别渠道要求单价*数量==总价
//            if([SMPCQuickSDK defaultInstance].channelType == 9999){
//                //通过判断渠道号处理特定渠道的参数
//                order.goodsID = @"productlist.name";
//            }
            int error = [[SMPCQuickSDK defaultInstance] payOrderInfo:order
                                                            roleInfo:role];
            if (error!=0)