This module provides various functions that the channel must integrate. The game must be connected to all interfaces to ensure that it is properly placed in the channel. This module is a mandatory module.
The game developer needs to read the public configuration and prepare relevant configuration.
Interface description: Invoke the channel login interface. If the login succeeds, there must be a callback. Otherwise, it is unsuccessful. If it is unsuccessful, there may be no callback. Please note.
Note 1: The game cannot rely on login failure callbacks to handle the game logic processing. (There are no callbacks of some channel’s login failures )
Note 2: Parse the json data of the login successful callback, and send the ticket to the game server for verification. If the game server is successfully verified, then the SuperSDK login is successful. For details, see the login server documentation.(../server/server)
Note 3: When the code returned from login result is less than or equal to -10000, the login of the channel SDK fails. The rest can be regarded as SuperSDK login verification failure or the network anomaly.
Interface invoke::
SuperSDK.invoke(BCoreConst.platform.MODULE_NAME, BCoreConst.platform.FUNC_LOGIN, null);
interface callback:
private OnSuperSDKListener mSuperSDKListener = new OnSuperSDKListener() {
@Override
public void onSuperSDK(String moduleName, String funcName, String result) {
//调用接口异步监听结果。
Log.d(TAG, "moduleName:" + moduleName + "\nfuncName:" + funcName + "\nresult:" + result);
//判断这是平台模块("platform")内的方法,并且方法为初始化("init")
if(BCoreConst.platform.MODULE_NAME.equals(moduleName) && BCoreConst.platform.FUNC_LOGIN.equals(funcName)) {
//登录回调,建议调用独立的处理方法
JSONObject json = JsonUtils.parseObject(result);
int code = json.getIntValue("code");
// 登录失败
if (BCoreCode.SUCCESS != code) {
String msg = json.getString("msg");
// 游戏在这里登录失败的逻辑
return;
}
JSONObject data = json.getJSONObject("data");
mAccessToken = data.getString("osdk_ticket");
// 请游戏把下面步骤放到服务器端解析,这里只做示例
String str = StringUtil.deBase64fromString(mAccessToken);
JSONObject jsonObj2 = JsonUtils.parseObject(str);
uid = jsonObj2.getString("osdk_user_id");
Log.e(TAG, "uid=" + uid);
Log.e(TAG, "token=" + mAccessToken);
}else {
Log.d("supersdk", "其他模块方法的监听结果");
}
}
};
Log printing::
moduleName:platform
funcName:login
result:
{
"code": 1,
"data": {
"data": {
"uid": "19"
},
"msg": "登录成功",
"osdk_ticket": "eyJvc2RrX2dhbWVfaWQiOiIxOTYzNzc1MzgiLCJ1c2VyX2lkIjoiMTkiLCJsb2dpbl9zZGtfbmFtZSI6IkRlbW8iLCJjaGFubmVsX2lkIjoiMTIzMiIsImV4dGVuZCI6IntcImV4dGVuZFwiOlwiMjE1MHw5NHwwXCIsXCJvdXRlcl9leHRlbmRcIjpcIjIxNTB8OTR8MFwifSIsImFjY291bnRfc3lzdGVtX2lkIjoiMDA2MTAwMCIsIm9zZGtfdXNlcl9pZCI6IjAwNjEwMDBfMTkiLCJpcCI6IjE5Mi4xNjguMTIyLjE0OSIsImNvdW50cnkiOiIwMCIsInRpbWUiOjE0OTg2NjczNjcsInNpZ24iOiIxOWY0MDAxYmEyYWVkMzBjMjk1NjQ5YWU1MDZkMTQyMCJ9",
"status": 1,
"userinfo": {
"login_sdk_name": "Demo",
"user_id": "19"
}
},
"msg": "login success"
}
Interface description: After successful login, log out the currently account and invoke the interface.
Note: This interface is used for switching game accounts. The portal is generally placed in the following scenarios::
1. Login scenario,display of the account is successfully logged in.
2、the main game scene, display of setting interface.
Interface invoke:
//这个接口可以判断第三方渠道是否有注销接口,如果游戏有特殊需求,可以判断该接口,再决定是否调用注销接口
boolean flag = SuperSDK.invokeBool(BCoreConst.platform.MODULE_NAME, BCoreConst.platform.FUNC_HAS_LOGOUT, null);
//注销接口,一般情况下,游戏可以直接调用该接口
SuperSDK.invoke(BCoreConst.platform.MODULE_NAME, BCoreConst.platform.FUNC_LOGOUT, null);
Interface callback:
private OnSuperSDKListener mSuperSDKListener = new OnSuperSDKListener() {
@Override
public void onSuperSDK(String moduleName, String funcName, String result) {
//调用接口异步监听结果。
Log.d(TAG, "moduleName:" + moduleName + "\nfuncName:" + funcName + "\nresult:" + result);
if(BCoreConst.platform.MODULE_NAME.equals(moduleName) && BCoreConst.platform.FUNC_LOGOUT.equals(funcName)) {
//注销回调,建议调用独立的处理方法
JSONObject json = JsonUtils.parseObject(result);
int code = json.getIntValue("code");
if(code == BCoreCode.SUCCESS) {
//注销成功,游戏重新返回登录页面
Log.d("supersdk", "注销成功,游戏重新返回登录页面");
} else {
//注销失败,游戏可以不做处理
String msg = json.getString("msg");
Log.d("supersdk", "注销失败:"+code+", "+msg);
}
}else {
Log.d("supersdk", "其他模块方法的监听结果");
}
}
};
Log printing:
moduleName:platform
funcName:logout
result:{"code":1,"msg":"logout success"}
Interface Description: Invoking when the game opens the login page. This interface is invoked when you open the login page for the first time, and it also need to be invoked when log back to the login page.
Interface invoke:
//到达登录页面
SuperSDK.invoke(BCoreConst.platform.MODULE_NAME, BCoreConst.platform.FUNC_OPEN_LOGIN_PAGE, null);
Interface description: The game needs to invoke role report in three places: enterGame, createRole, levelUp
Note: You need to ensure that the “enterGame” is invoked before the “createRole”. There might be two scenarios:
* Enter the game first, then create a role. The first time you enter the game, there is no data, don’t report it. After the first time, if there is data while entering the game, report it. 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 enterGame interface first, and then invoke createRole interface. Do not repeatedly invoke enterGame interface when entering the game. When the user has a role, the enterGame interface can be invoked upon entering the game.
Interface invoke:
//通用参数
Map<String, String> params = new HashMap<String, String>();
params.put(BCoreConst.platform.KEY_ROLE_ID, "roleId"); // 必传,游戏创建的角色ID
params.put(BCoreConst.platform.KEY_ROLE_NAME, "roleName"); // 必传,角色名称
params.put(BCoreConst.platform.KEY_ROLE_LEVEL, "roleLevel"); // 必传,角色等级,必须为整形数字
params.put(BCoreConst.platform.KEY_VIP_GRADE, "vip"); // 必传,角色vip,必须为数字,如VIP1,则传1
params.put(BCoreConst.platform.KEY_SERVER_ID, "serverId"); // 必传,服务器ID
params.put(BCoreConst.platform.KEY_SERVER_NAME, "serverName"); // 必传,服务器名称
params.put(BCoreConst.platform.KEY_OP_SID, "opSid"); // 必传,渠道服务器ID
//UC等渠道要求参数
params.put(BCoreConst.platform.KEY_ROLE_CREATE_TIME, "roleCreateTime");//必传,创角时间,必须为服务器时间,必须为10位数字,如1498043738
//奇虎360渠道要求参数
params.put("professionid", "6"); // 必传,职业ID,必须为数字,如果有则必传,如果没有,请说明原因
params.put("profession", "武士"); // 必传,职业名称,如果有则必传,如果没有,请说明原因
params.put("gender", "男"); // 必传,性别,只能传"男"、"女",如果有则必传,如果没有,请说明原因
params.put("power", "132323000"); // 必传,战力数值,必须为数字,如果有则必传,如果没有,请说明原因
params.put("balance", "0"); // 必传,帐号余额,必须为数字,如果有则必传,如果没有,请说明原因
params.put("partyid", "120"); // 必传,所属帮派帮派ID,必须为数字,如果有则必传,如果没有,请说明原因
params.put("partyname", "一笑倾城"); // 必传,所属帮派名称,如果有则必传,如果没有,请说明原因
params.put("partyroleid", "1"); // 必传,帮派称号ID,必须为数字,帮主/会长必传1,其他可自定义,如果有则必传,如果没有,请说明原因
params.put("partyrolename", "帮主");// 必传,帮派称号名称,如果有则必传,如果没有,请说明原因
params.put("friendlist", "[{\"roleid\":1,\"intimacy\":\"0\",\"nexusid\":\"600\",\"nexusname\":\"情侣\"},{\"roleid\":2,\"intimacy\":\"1\",\"nexusid\":\"200\",\"nexusname\":\"仇人\"}]");
// 必传,好友关系,如果有则必传,如果没有,请说明原因
//A站渠道要求参数
params.put("isNewPlayer", "true"); // 必传,是否为第一次创角,只能传"true"、"false"。
//调用进入游戏接口,必须在创建角色接口前调用
SuperSDK.invoke(BCoreConst.platform.MODULE_NAME, BCoreConst.platform.FUNC_ENTER_GAME, params);
Interface description: The game needs to invoke the role report in three places: enterGame, createRole, levelUp
Note: You need to ensure that the “enterGame” is invoked before the “createRole”. There might be two scenarios:
* Enter the game first, then create a role. The first time you enter the game, there is no data, don’t report it. After the first time, if there is data while entering the game, report it. 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 enterGame interface first, and then invoke createRole interface. Do not repeatedly invoke enterGame interface when entering the game. When the user has a role, the enterGame interface can be invoked upon entering the game.
Interface invoke:
Map<String, String> params = new HashMap<String, String>();
params.put(BCoreConst.platform.KEY_ROLE_ID, "roleId"); // 必传,游戏创建的角色ID
params.put(BCoreConst.platform.KEY_ROLE_NAME, "roleName"); // 必传,角色名称
params.put(BCoreConst.platform.KEY_ROLE_LEVEL, "roleLevel"); // 必传,角色等级,必须为整形数字
params.put(BCoreConst.platform.KEY_VIP_GRADE, "vip"); // 必传,角色vip,必须为数字,如VIP1,则传1
params.put(BCoreConst.platform.KEY_SERVER_ID, "serverId"); // 必传,服务器ID
params.put(BCoreConst.platform.KEY_SERVER_NAME, "serverName"); // 必传,服务器名称
params.put(BCoreConst.platform.KEY_OP_SID, "opSid"); // 必传,渠道服务器ID
//UC等渠道要求参数
params.put(BCoreConst.platform.KEY_ROLE_CREATE_TIME, "roleCreateTime");//必传,创角时间,必须为服务器时间,必须为10位数字,如1498043738
//奇虎360渠道要求参数
params.put("professionid", "6"); // 必传,职业ID,必须为数字,如果有则必传,如果没有,请说明原因
params.put("profession", "武士"); // 必传,职业名称,如果有则必传,如果没有,请说明原因
params.put("gender", "男"); // 必传,性别,只能传"男"、"女",如果有则必传,如果没有,请说明原因
params.put("power", "132323000"); // 必传,战力数值,必须为数字,如果有则必传,如果没有,请说明原因
params.put("balance", "0"); // 必传,帐号余额,必须为数字,如果有则必传,如果没有,请说明原因
params.put("partyid", "120"); // 必传,所属帮派帮派ID,必须为数字,如果有则必传,如果没有,请说明原因
params.put("partyname", "一笑倾城"); // 必传,所属帮派名称,如果有则必传,如果没有,请说明原因
params.put("partyroleid", "1"); // 必传,帮派称号ID,必须为数字,帮主/会长必传1,其他可自定义,如果有则必传,如果没有,请说明原因
params.put("partyrolename", "帮主");// 必传,帮派称号名称,如果有则必传,如果没有,请说明原因
params.put("friendlist", "[{\"roleid\":1,\"intimacy\":\"0\",\"nexusid\":\"600\",\"nexusname\":\"情侣\"},{\"roleid\":2,\"intimacy\":\"1\",\"nexusid\":\"200\",\"nexusname\":\"仇人\"}]");
// 必传,好友关系,如果有则必传,如果没有,请说明原因
//A站渠道要求参数
params.put("isNewPlayer", "true"); // 必传,是否为第一次创角,只能传"true"、"false"。
//调用创建角色接口
SuperSDK.invoke(BCoreConst.platform.MODULE_NAME, BCoreConst.platform.FUNC_CREATE_ROLE, params);
Interface description: The game needs to invoke the role report in three places: enterGame, createRole, levelUp
Interface invoke:
Map<String, String> params = new HashMap<String, String>();
params.put(BCoreConst.platform.KEY_ROLE_ID, "roleId"); // 必传,游戏创建的角色ID
params.put(BCoreConst.platform.KEY_ROLE_NAME, "roleName"); // 必传,角色名称
params.put(BCoreConst.platform.KEY_ROLE_LEVEL, "roleLevel"); // 必传,角色等级,必须为整形数字
params.put(BCoreConst.platform.KEY_VIP_GRADE, "vip"); // 必传,角色vip,必须为数字,如VIP1,则传1
params.put(BCoreConst.platform.KEY_SERVER_ID, "serverId"); // 必传,服务器ID
params.put(BCoreConst.platform.KEY_SERVER_NAME, "serverName"); // 必传,服务器名称
params.put(BCoreConst.platform.KEY_OP_SID, "opSid"); // 必传,渠道服务器ID
//UC等渠道要求参数
params.put(BCoreConst.platform.KEY_ROLE_CREATE_TIME, "roleCreateTime");//必传,创角时间,必须为服务器时间,必须为10位数字,如1498043738
//奇虎360渠道要求参数
params.put("professionid", "6"); // 必传,职业ID,必须为数字,如果有则必传,如果没有,请说明原因
params.put("profession", "武士"); // 必传,职业名称,如果有则必传,如果没有,请说明原因
params.put("gender", "男"); // 必传,性别,只能传"男"、"女",如果有则必传,如果没有,请说明原因
params.put("power", "132323000"); // 必传,战力数值,必须为数字,如果有则必传,如果没有,请说明原因
params.put("balance", "0"); // 必传,帐号余额,必须为数字,如果有则必传,如果没有,请说明原因
params.put("partyid", "120"); // 必传,所属帮派帮派ID,必须为数字,如果有则必传,如果没有,请说明原因
params.put("partyname", "一笑倾城"); // 必传,所属帮派名称,如果有则必传,如果没有,请说明原因
params.put("partyroleid", "1"); // 必传,帮派称号ID,必须为数字,帮主/会长必传1,其他可自定义,如果有则必传,如果没有,请说明原因
params.put("partyrolename", "帮主");// 必传,帮派称号名称,如果有则必传,如果没有,请说明原因
params.put("friendlist", "[{\"roleid\":1,\"intimacy\":\"0\",\"nexusid\":\"600\",\"nexusname\":\"情侣\"},{\"roleid\":2,\"intimacy\":\"1\",\"nexusid\":\"200\",\"nexusname\":\"仇人\"}]");
// 必传,好友关系,如果有则必传,如果没有,请说明原因
//A站渠道要求参数
params.put("isNewPlayer", "true"); // 必传,是否为第一次创角,只能传"true"、"false"。
//调用角色升级接口
SuperSDK.invoke(BCoreConst.platform.MODULE_NAME, BCoreConst.platform.FUNC_LEVEL_UP, params);
Interface Description: Invoking when opens the home page of the game.
Note 1: If it’s a new user enters for the first time, be sure to invoke it after the “createRole” interface.
Interface invoke:
//到达游戏主页面
SuperSDK.invoke(BCoreConst.platform.MODULE_NAME, BCoreConst.platform.FUNC_OPEN_HOME_PAGE, null);
Interface Description: Some additional interfaces to the channel, some channels have these interfaces, and some channels do not have these interfaces. A judgment is required to invoke these interfaces.
Note 1: You need to judge whether the channel has a Forum, User Center, Customer Service interface. If required, you need to provide the corresponding UI in the game settings interface, if not, hide it.
Interface invoke:
//是否有论坛
boolean hasForum = SuperSDK.invokeBool(BCoreConst.platform.MODULE_NAME, BCoreConst.platform.FUNC_HAS_FORUM, null);
if(hasForum) {
//如果有论坛,打开论坛
SuperSDK.invoke(BCoreConst.platform.MODULE_NAME, BCoreConst.platform.FUNC_OPEN_FORUM, null);
}
//是否有用户中心
boolean hasUserCenter = SuperSDK.invokeBool(BCoreConst.platform.MODULE_NAME, BCoreConst.platform.FUNC_HAS_USER_CENTER, null);
if(hasUserCenter) {
//如果有用户中心,打开用户中心
SuperSDK.invoke(BCoreConst.platform.MODULE_NAME, BCoreConst.platform.FUNC_OPEN_USER_CENTER, null);
}
//是否有客服
boolean hasCustomServer = SuperSDK.invokeBool(BCoreConst.platform.MODULE_NAME, BCoreConst.platform.FUNC_HAS_CUSTOMER_SERVICE, null);
if(hasCustomServer) {
//如果有客服,打开客服
SuperSDK.invoke(BCoreConst.platform.MODULE_NAME, BCoreConst.platform.FUNC_OPEN_CUSOMER_SERVICE, null);
}
Interface Description: This interface is used to close the game. Invoking when clicking the “close game” button or pressing Android’s return button.
Note 1: Overseas games need to implement the exit confirmation pop-up windows.
Note 2: If this interface is not integrated, it will affect the destruction of the channel SDK resources, causing some channel games to fail to start next time.
Note 3: Please invoke this interface when event listening to the down method of the back button. Do not event listening for up and other methods.
Interface invoke:
SuperSDK.invoke(BCoreConst.platform.MODULE_NAME, BCoreConst.platform.FUNC_EXIT, null);
Interface callback:
private OnSuperSDKListener mSuperSDKListener = new OnSuperSDKListener() {
@Override
public void onSuperSDK(String moduleName, String funcName, String result) {
//调用接口异步监听结果。
Log.d(TAG, "moduleName:" + moduleName + "\nfuncName:" + funcName + "\nresult:" + result);
if (BCoreConst.platform.MODULE_NAME.equals(moduleName) && BCoreConst.platform.FUNC_EXIT.equals(funcName)) {
//退出回调
JSONObject json = JsonUtils.parseObject(result);
int code = json.getIntValue("code");
if(code == BCoreCode.SUCCESS) {
//弹出关闭窗口,并且玩家点击了确认
Log.d("supersdk", "退出确认,游戏需把自己关闭");
} else {
//弹出关闭窗口,但是玩家取消了,游戏可以不做任何事
String msg = json.getString("msg");
Log.d("supersdk", "退出取消:"+code+", "+msg);
}
} else {
Log.d("supersdk", "其他模块方法的监听结果");
}
}
};
Log printing:
moduleName:platform
funcName:exit
result:{"code":1,"msg":"exit success"}
Constant string | Actual string | Description |
---|---|---|
BCoreConst.platform.MODULE_NAME | platform | Platform module name |
login | ||
BCoreConst.platform.FUNC_LOGIN | login | Login method |
logout | ||
BCoreConst.platform.FUNC_HAS_LOGOUT | hasLogout | Whether the channel has a logout interface |
BCoreConst.platform.FUNC_LOGOUT | logout | Logout interface |
pay | ||
BCoreConst.platform.FUNC_PAY | pay | Open the payment page |
BCoreConst.platform.FUNC_PAY_ORDER_ID | payOrderId | Successfully get the order number callback |
BCoreConst.platform.KEY_PRICE | price | Recharge amount |
BCoreConst.platform.KEY_PRODUCT_ID | productId | Product ID |
BCoreConst.platform.KEY_PRODUCT_NAME | productName | product name |
BCoreConst.platform.KEY_PRODUCT_DESC | productDesc | product description |
BCoreConst.platform.KEY_POINT_RATE | pointRate | The ratio of real currency to game currency exchange, such as 1:10, fill in 10 |
BCoreConst.platform.KEY_POINT_NAME | pointName | Game currency name, such as diamond |
BCoreConst.platform.KEY_ORDER_TITLE | orderTitle | Order title |
Role data report | ||
BCoreConst.platform.FUNC_ENTER_GAME | enterGame | Enter the game interface |
BCoreConst.platform.FUNC_CREATE_ROLE | createRole | Create a role interface |
BCoreConst.platform.FUNC_LEVEL_UP | levelUp | level Up interface |
BCoreConst.platform.KEY_ROLE_ID | role_id | Role ID |
BCoreConst.platform.KEY_ROLE_NAME | role_name | Role Name |
BCoreConst.platform.KEY_ROLE_LEVEL | level | Role level |
BCoreConst.platform.KEY_VIP_GRADE | vip_grade | Role vip |
BCoreConst.platform.KEY_SERVER_ID | server_id | Server ID |
BCoreConst.platform.KEY_SERVER_NAME | server_name | Server name |
BCoreConst.platform.KEY_OP_SID | opSid | Channel server ID |
BCoreConst.platform.KEY_ROLE_CREATE_TIME | roleCreateTime | To create a role time, you must use server time, unit / s |
Forum, UserCenter,CustomerService | ||
BCoreConst.platform.FUNC_HAS_FORUM | hasForum | whether there is a forum |
BCoreConst.platform.FUNC_OPEN_FORUM | openForum | Open forum |
BCoreConst.platform.FUNC_HAS_USER_CENTER | hasUserCenter | whether there is a user center |
BCoreConst.platform.FUNC_OPEN_USER_CENTER | openUserCenter | Open the user center |
BCoreConst.platform.FUNC_HAS_CUSTOMER_SERVICE | hasCustomerService | whether there is a customer service |
BCoreConst.platform.FUNC_OPEN_CUSOMER_SERVICE | openCustomerService | Open customer service |
Exit the game | ||
BCoreConst.platform.FUNC_EXIT | exit | Exit the game |
open login page, open home page | ||
BCoreConst.platform.FUNC_OPEN_LOGIN_PAGE | openLoginPage | Open the login page |
BCoreConst.platform.FUNC_OPEN_HOME_PAGE | openHomePage | Open the homepage |
Add supersdk event tracking | ||
BCoreConst.platform.FUNC_REPORT | report | Add a event tracking method name |
BCoreConst.platform.KEY_EVENT_ID | event_id | Event ID |