supersdk

文档中心

文档中心

下载文档

Login module


This module provides the relevant interfaces that must be integrated by the channel on the game. All interfaces must be connected to ensure that they can be placed on the channel. This module is a mandatory module.

Preparation before integration

The game developer needs to read thepublic configuration,and configure it.

login

Interface Description: Invoking this interface will open the login window of the channel.

Note 1: The game cannot rely on callbacks which fail to log in for game logic processing. (There are no login failures callbacks of some channels)

Note 2: Parse the json data of the successful callback, and send the ticket to the game server for verification. The game server is successfully verified, that is, the SuperSDK login is successful. For details, see the login server documentation

Note 3: When the code returned in the result of the login is less than or equal to -10000, the login of the channel SDK fails. The rest are SuperSDK login verification failure or network abnormal.

Interface invoke:

[SuperSDK invoke:BCORE_MODULE_PLATFORM funcName:BCORE_FUNC_LOGIN parameters:nil];

Interface callback:

- (void)handlerCallback:(NSString *)moduleName funcName:(NSString *)funcName result:(NSString *)result {
    
    // 处理SuperSDK回调逻辑,注意,所有模块回调都在这里。
    NSLog(@"****** 收到回调\n moduleName : %@,\n funcName : %@,\n result : %@", moduleName, funcName, result);
    
    // 1.回调参数解析
    NSDictionary *retParam = nil;
    if (result) {
        NSData *jsonData = [result dataUsingEncoding:NSUTF8StringEncoding];
        if (jsonData) {
            retParam = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableLeaves error:nil];
        }
    }
    
    int code            = [[retParam objectForKey:@"code"] intValue];   // 状态码
    NSString *msg       = [retParam objectForKey:@"msg"];               // 说明
    
    // 2.回调参数判断
    if ([moduleName isEqualToString:BCORE_MODULE_PLATFORM]) {// 平台模块回调
        
        if ([funcName isEqualToString:BCORE_FUNC_LOGIN]) {// 登录回调
            
            if (code == BCORE_SUCCESS) {
                // 平台登陆成功,需要将osdk_ticket拿到游戏服务器去验证一下,以确定用户信息的合法性
                NSDictionary *data  = [retParam objectForKey:@"data"]; // 回调data数据
                NSString *ticket = [data objectForKey:@"osdk_ticket"];//拿到ticket 去游戏服务器做登陆验证
                
            } 
            else {
                NSLog(@"平台登陆失败,code=%d ,原因是 %@",code, msg);
            }
        }
    }
}

Callback log printing:

2017-07-04 15:09:46.457637+0800 Demo_Mubao[1209:349856] ****** 收到回调
 moduleName : platform,
 funcName : login,
 result : {
  "msg" : "登录成功", 
  "data" : {
    "status" : 1,
    "data" : {
      "uid" : "227"
    },
    "msg" : "登录成功",
    "osdk_ticket" : "eyJvc2RrX2dhbWVfaWQiOiIxOTYzNzc0MjYiLCJ1c2VyX2lkIjoiMjI3IiwibG9naW5fc2RrX25hbWUiOiJEZW1vIiwiY2hhbm5lbF9pZCI6IjAiLCJleHRlbmQiOiIyMTUwfDEyM3wwIiwiYWNjb3VudF9zeXN0ZW1faWQiOiIwMDYwMDAwIiwib3Nka191c2VyX2lkIjoiMDA2MDAwMF8yMjciLCJpcCI6IjYxLjE3NC4xNS4yMjkiLCJjb3VudHJ5IjoiQ04iLCJ0aW1lIjoxNDk5MTUyMTgyLCJzaWduIjoiZGFjYzZkZjI4ODVkZTRmNzg2N2U5OGI0ZGFjY2U3YjUifQ==",
    "userinfo" : {
      "user_id" : "227",
      "login_sdk_name" : "Demo"
    }
  },
  "code" : 1
}

Logout

Interface Description: Invoking this interface will pop up the channel logout confirmation window.

Note: This interface is used for game account switching. The portal is normally placed in the following scenarios:

1. Login scenario, the account login is successfully displayed.

2, the main game scene, setting interface is displayed.

3. Log in to multiple devices with the same account. The latter will log out the previous account and the SDK, that is, when the account is logged out by the latter account, you need to invoke this interface! ! !

Interface invoke:

// 注销接口,第三方渠道没有注销接口的情况下,调用该接口,默认注销成功
[SuperSDK invoke:BCORE_MODULE_PLATFORM funcName:BCORE_FUNC_LOGOUT parameters:nil];
// 另外,这个接口可以判断第三方渠道是否有注销接口,如果游戏有特殊需求,可以判断该接口,再决定是否调用注销接口
BOOL hasLogout = [SuperSDK invokeBool:BCORE_MODULE_PLATFORM funcName:BCORE_FUNC_HAS_LOGOUT parameters:nil];

Interface callback:

- (void)handlerCallback:(NSString *)moduleName funcName:(NSString *)funcName result:(NSString *)result {
    
    // 处理SuperSDK回调逻辑,注意,所有模块回调都在这里。
    NSLog(@"****** 收到回调\n moduleName : %@,\n funcName : %@,\n result : %@", moduleName, funcName, result);
    
    
    // 1.回调参数解析
    NSDictionary *retParam = nil;
    if (result) {
        NSData *jsonData = [result dataUsingEncoding:NSUTF8StringEncoding];
        if (jsonData) {
            retParam = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableLeaves error:nil];
        }
    }
    
    int code            = [[retParam objectForKey:@"code"] intValue];   // 状态码
    NSString *msg       = [retParam objectForKey:@"msg"];               // 说明
    
    // 2.回调参数判断
    if ([moduleName isEqualToString:BCORE_MODULE_PLATFORM]) {// 平台模块回调
        
        if ([funcName isEqualToString:BCORE_FUNC_LOGOUT]) {// 注销回调
            if (code == BCORE_SUCCESS) {
                NSLog(@"********注销成功*********");
            }
            else {
                NSLog(@"********注销失败*********");
            }
        }
    }
}

Callback log printing:

2017-07-04 15:16:10.939141+0800 Demo_Mubao[1219:351266] ****** 收到回调
 moduleName : platform,
 funcName : logout,
 result : {
  "msg" : "注销成功",
  "code" : 1
}

Arrival login page (required)

Interface description: After the game is started, you need to invoke this interface before invoking the login interface after the login scenario is reached.

Interface invoke:

[SuperSDK invoke:BCORE_MODULE_PLATFORM funcName:BCORE_FUNC_OPEN_LOGIN_PAGE parameters:nil];

EnterGame (required)

Interface description: When the game enters the main scene from the login scene or the create role scene, the interface needs to be invoked to report data.

Note: You need to ensure that the “enterGame” event is invoked before the “create Role” event. There might be two situations:

* Enter the game first, then create the role. The first time you enter the game, there is no data, don’t report it. After the first time, you will get data and report it when you enter the game. But the game needs to invoke the enterGame interface first, then invoke the createRole interface.

* Create a role first, then enter the game. When creating a role, the game needs to invoke the enterGame interface first, and then invoke the createRole interface. And do not repeatedly invoke the enterGame interface when entering the game. When the user has a role, the enterGame interface can be invoked upon entering the game.

Interface invoke:

NSString *serverId   = @"100000001";    // 服务器id
NSString *serverName = @"测试服";        // 服务器名称
NSString *roleId     = @"g1029388822";  // 角色id
NSString *roleName   = @"墨韵";          // 角色名字
NSString *level      = @"125";          // 角色等级
NSString *vipGrade   = @"15";           // VIP等级
NSString *opSid      = @"12345";        // 运营商服务器id,默认和服务器id相同
NSString *roleCreateTime = @"1501569251";// 创角时间,10位时间戳,精确到秒
    
NSDictionary *gameInfo = @{
                           @"server_id"    : serverId,
                           @"server_name"  : serverName,
                           @"role_id"      : roleId,
                           @"role_name"    : roleName,
                           @"level"        : level,
                           @"vip_grade"    : vipGrade,
                           @"opSid"        : opSid,
                           @"roleCreateTime" : roleCreateTime
                           };
                
// 调用进入游戏接口
[SuperSDK invoke:BCORE_MODULE_PLATFORM funcName:BCORE_FUNC_ENTER_GAME parameters:gameInfo];

createRole (required)

Interface description: After successfully creating a role, you need to invoke this interface to report data.

Note: You need to ensure that the “enterGame” event is invoked before the “createRole” event. There might be two situations:

* Enter the game first, then create the role. The first time you enter the game, there is no data, don’t report it. After the first time, you will get data and report it when you enter the game. But the game needs to invoke the enterGame interface first, then invoke the createRole interface.

* Create a role first, then enter the game. When creating a role, the game needs to invoke the enterGame interface first, and then invoke the createRole interface. And do not repeatedly invoke the enterGame interface when entering the game. When the user has a role, the enterGame interface can be invoked upon entering the game.

Interface invoke:

NSString *serverId   = @"100000001";    // 服务器id
NSString *serverName = @"测试服";        // 服务器名称
NSString *roleId     = @"g1029388822";  // 角色id
NSString *roleName   = @"墨韵";          // 角色名字
NSString *level      = @"1";            // 角色等级
NSString *vipGrade   = @"0";            // VIP等级
NSString *opSid      = @"12345";        // 运营商服务器id,默认和服务器id相同
NSString *roleCreateTime = @"1501569251";// 创角时间,10位时间戳,精确到秒
    
NSDictionary *gameInfo = @{
                           @"server_id"    : serverId,
                           @"server_name"  : serverName,
                           @"role_id"      : roleId,
                           @"role_name"    : roleName,
                           @"level"        : level,
                           @"vip_grade"    : vipGrade,
                           @"opSid"        : opSid,
                           @"roleCreateTime" : roleCreateTime
                           };
                
// 调用创建角色接口
[SuperSDK invoke:BCORE_MODULE_PLATFORM funcName:BCORE_FUNC_CREATE_ROLE parameters:gameInfo];

levelUp(required)

Interface description: When the role’s level upgraded, you need to invoke this interface to report data.

Interface invoke:

NSString *serverId   = @"100000001";    // 服务器id
NSString *serverName = @"测试服";        // 服务器名称
NSString *roleId     = @"g1029388822";  // 角色id
NSString *roleName   = @"墨韵";          // 角色名字
NSString *level      = @"100";          // 角色等级
NSString *vipGrade   = @"10";           // VIP等级
NSString *opSid      = @"12345";        // 运营商服务器id,默认和服务器id相同
NSString *roleCreateTime = @"1501569251";// 创角时间,10位时间戳,精确到秒
    
NSDictionary *gameInfo = @{
                           @"server_id"    : serverId,
                           @"server_name"  : serverName,
                           @"role_id"      : roleId,
                           @"role_name"    : roleName,
                           @"level"        : level,
                           @"vip_grade"    : vipGrade,
                           @"opSid"        : opSid,
                           @"roleCreateTime" : roleCreateTime
                           };
                
// 调用角色升级接口
[SuperSDK invoke:BCORE_MODULE_PLATFORM funcName:BCORE_FUNC_LEVEL_UP parameters:gameInfo];

Arrive at the main game page (required)

Interface Description: when the player enters the main game scene, you need to invoke this interface to report data.

Note 1: If it is a new user enters the game for the first time, be sure to invoke it after the “createRole” interface.

Interface invoke:

// 打开游戏首页时调用
[SuperSDK invoke:BCORE_MODULE_PLATFORM funcName:BCORE_FUNC_OPEN_HOME_PAGE parameters:nil];

Forum, user center, customer service (required)

Interface description: channel expansion interface, invoke forum, user center, customer service and other interfaces will open the corresponding function interfaces of the channel.

Note 1: You need to judge whether the channel has a forum, user center, customer service interface. If it has any of them, you need to provide the corresponding UI entry in the game settings interface, if not, hide it.

Interface invoke:

// 论坛
if ([SuperSDK invokeBool:BCORE_MODULE_PLATFORM funcName:BCORE_FUNC_HAS_FORUM parameters:nil]) {
   // 游戏设置中,显示打开论坛按钮
}
else {
   // 游戏设置中,隐藏打开论坛按钮
}
// 论坛按钮点击事件,调用该接口,打开论坛
[SuperSDK invoke:BCORE_MODULE_PLATFORM funcName:BCORE_FUNC_OPEN_FORUM parameters:nil];
// 用户中心
if ([SuperSDK invokeBool:BCORE_MODULE_PLATFORM funcName:BCORE_FUNC_HAS_USER_CENTER parameters:nil]) {
   // 游戏设置中,显示打开用户中心按钮
}
else {
   // 游戏设置中,隐藏打开用户中心按钮
}
// 用户中心按钮点击事件,调用该接口,打开用户中心
[SuperSDK invoke:BCORE_MODULE_PLATFORM funcName:BCORE_FUNC_OPEN_USER_CENTER parameters:nil];
// 客服
if ([SuperSDK invokeBool:BCORE_MODULE_PLATFORM funcName:BCORE_FUNC_HAS_CUSOMER_SERVICE parameters:nil]) {
   // 游戏设置中,显示打开客服按钮
}
else {
   // 游戏设置中,隐藏打开客服按钮
}
// 客服按钮点击事件,调用该接口,打开客服
[SuperSDK invoke:BCORE_MODULE_PLATFORM funcName:BCORE_FUNC_OPEN_CUSOMER_SERVICE parameters:nil];

Add SuperSDK event tracking

Interface description: SuperSDK adds some event trackings in some interfaces. If the game needs to add some event trackings, you can invoke this interface. The data reported by this interface will be displayed in the SuperSDK background.

Interface invoke:

[SuperSDK invoke:BCORE_MODULE_PLATFORM funcName:BCORE_FUNC_REPORT parameters:@{
                                                                             @"event_id" : @"事件ID",
                                                                             @"desc"     : @"事件描述信息"
                                                                                    }];

Appendix

Constant string Actual string Description
BCORE_MODULE_PLATFORM platform Platform module
BCORE_FUNC_LOGIN login Login method
BCORE_MODULE_PLATFORM platform Platform module
BCORE_FUNC_HAS_LOGOUT hasLogout Whether the channel has a logout interface
BCORE_FUNC_LOGOUT logout Logout interface
BCORE_MODULE_PLATFORM platform Platform module
BCORE_FUNC_ENTER_GAME enterGame Enter game interface
BCORE_FUNC_CREATE_ROLE createRole Create a role interface
BCORE_FUNC_LEVEL_UP levelUp levelup interface
BCORE_KEY_ROLE_ID role_id Role ID
BCORE_KEY_ROLE_NAME role_name Role Name
BCORE_KEY_ROLE_LEVEL level Role level
BCORE_KEY_VIP_GRADE vip_grade Role vip
BCORE_KEY_SERVER_ID server_id Server ID
BCORE_KEY_SERVER_NAME server_name name of server
BCORE_KEY_OPSID opSid Channel server ID
BCORE_KEY_ROLE_CREATE_TIME roleCreateTime role create time, you must use server time in seconds.
BCORE_MODULE_PLATFORM platform Platform module
BCORE_FUNC_HAS_FORUM hasForum whether there is a forum?
BCORE_FUNC_OPEN_FORUM openForum Open forum
BCORE_FUNC_HAS_USER_CENTER hasUserCenter whether there is a user center?
BCORE_FUNC_OPEN_USER_CENTER openUserCenter Open the user center
BCORE_FUNC_HAS_CUSOMER_SERVICE hasCustomerService whether there is a customer service?
BCORE_FUNC_OPEN_CUSOMER_SERVICE openCustomerService Open customer service
BCORE_MODULE_PLATFORM platform Platform module
BCORE_FUNC_EXIT exit Exit the game