01/10/2025 10:53:00
Account inconsistency and third-party channel parameter transparent transmission functions
I. Function description
[Info] Special Description The following functions need to be tested in detail to meet the specific needs of the game
1.1 Third-party channel parameter transparent transmission function
The game can be launched in the third-party APP (for example, the game can be launched through the player's invitation or through the Game Center). In this case, the game needs to use the parameters carried by the third-party APP for subsequent processing, and MSDK will transmit these parameters transparently to the game.
Application scenario example: The player can directly enter the game and enter the game team by clicking the invitation sent by other friends through WeChat.
1.2 Account inconsistency
The account authorized in the game is different from the account authorized in the third-party channel (such as QQ/WeChat). This scenario is called account inconsistency.
Application scenario example: The WeChat account logged in by the game now is different from the account in WeChat APP. After the player starts the game through the game center, the game will prompt the player to choose which account to continue playing the game.
[Info] Special Description Generally, channels (currently, only WeChat and QQ need to handle this issue) do not need to handle account inconsistency. And the account inconsistency logic is relatively complicated. If there is no special requirement on this issue, the issue can be ignored.
II. Client plugin development
2.1 Android platform
2.1.1 Class implementation rule description
Account inconsistency and third-party channel parameter transparent transmission need to first configure life cycle monitoring. For details, please refer to Life Cycle Processing .
Use the same class (LifeCycleObserver) for life cycle monitoring, and just add the implementation of the IWakeup
interface.
- Package name rule: fixed as
com.tencent.gcloud.msdk
- Class name rule:
channel name (case sensitive) + LifeCycleObserver
, such as:GarenaLifeCycleObserver
- Must implement
IWakeup
interface
2.1.2 Callback field description
As for the callback function description,, please refer to Client plugin development rules
observerID
callback function IDMSDKObserverID.MSDK_PLATFORM_WAKE_UP
is used to return the login status information or transparently transmitted parameter information when the game is launched via a third-party channel.
ret
return structure- Must be
MSDKLoginPluginInfo
data structure - If you only develop the third-party channel parameter transparent transmission function, you only need to fill in
seqID
,channel
,channelID
andextraJson
inMSDKLoginPluginInfo
. Don't fill inchannelOpenID
andpluginData
fields . - If you need to develop the account inconsistency function, you need to fill in
channelOpenID
in addition toseqID
,channel
andchannelID
fields, and can optionally fill inpluginData
. If you need to transparently transmit the parameters of the third-party channel, you only need to fill inextraJson
in Json format.
- Must be
2.1.3 IWakeup interface
NotifyReceiveIntent function
Process the information carried when the third-party APP launches the game, and return the corresponding player login status or special parameter information.
2.1.4 Code example
1.Only provide third-party channel parameter transparent transmission function
package com.tencent.gcloud.msdk;
public class GarenaLifeCycleObserver implements ILifeCycle, IWakeup {
// TODO
... omit the method that ILifeCycle needs to implement
@Override
public void notifyReceiveIntent(Intent intent){
try {
if(intent != null) {
// TODO Get Garena feature information from intent
...
// Judge whether it is a Garena APP akip and a non-login request
if(fromGarena) {
// TODO Get Garena parameter information from intent
...
// Assemble callback data
MSDKLoginPluginInfo loginWakeupRet = new MSDKLoginPluginInfo();
loginWakeupRet.seqID = IT.createSequenceId();
// channel channelID is a required parameter
loginWakeupRet.channel = GarenaConst.Channel.MSDK_GARENA_CHANNEL;
loginWakeupRet.channelID = GarenaConst.Channel.MSDK_GARENA_CHANNEL_ID;
// Assemble the data extraJson transparently transmitted to the game
JSONObject extraJson = new JSONObject();
// Place all the information obtained by the third-party APP akip in the extraJson.params field in the Json format
JSONObject paramsData = new JSONObject();
paramsData.put("openid", openid);
// TODO ...
extraJson.put("params", paramsData.toString());
// Get the data brought to the game by transparent transmission, and put it in the game_data field
extraJson.put("game_data", gameData);
// Write extraJson data into the callback data structure
loginWakeupRet.extraJson = extraJson.toString();
// Call the data back to MSDKCore for subsequent judgments of account inconsistency and team information, etc.
IT.onPluginRetCallback(MSDKObserverID.MSDK_PLATFORM_WAKE_UP, loginWakeupRet, loginWakeupRet.seqID);
}
} else {
MSDKLog.e("Garena notifyReceiveIntent is null ");
}
} catch (Exception e) {
MSDKLog.e("Garena notifyReceiveIntent error : " + e.getMessage());
}
}
}
If you don't need to develop an account inconsistency function, you just need to fill in seqID
, channel
, channelID
and extraJson
in MSDKLoginPluginInfo
. Don't fill in channelOpenID
and pluginData
fields.
[info] For details, please refer to Demo code
2.Provide account inconsistency and third-party channel parameter transparent transmission functions
package com.tencent.gcloud.msdk;
public class GarenaLifeCycleObserver implements ILifeCycle, IWakeup {
// TODO
... omit the method that ILifeCycle needs to implement
@Override
public void notifyReceiveIntent(Intent intent){
try {
if(intent != null) {
// TODO Get Garena feature information from intent
...
// Judge whether it is a Garena APP akip and a non-login request
if(fromGarena) {
// TODO Get Garena parameter information from intent
...
// Assemble callback data
MSDKLoginPluginInfo loginWakeupRet = new MSDKLoginPluginInfo();
loginWakeupRet.seqID = IT.createSequenceId();
// channel channelID is a required parameter
loginWakeupRet.channel = GarenaConst.Channel.MSDK_GARENA_CHANNEL;
loginWakeupRet.channelID = GarenaConst.Channel.MSDK_GARENA_CHANNEL_ID;
// If you can get the `openid` of the current channel user, you can fill in `channelOpenID`. It can be used to determine in MSDKCore whether the currently logged-in player in the game is the same as the logged-in player in APP
loginWakeupRet.channelOpenID = openid;
// [Optional] If you can get the same channel data as the data gotten when logging in the game, you can fill in the data in `pluginData`. These data will be transparently transmitted to the backend for login
JSONObject pluginData = new JSONObject();
pluginData.put("uid", uid);
pluginData.put("token", token);
loginWakeupRet.pluginData = pluginData.toString();
// Assemble the data extraJson transparently transmitted to the game
JSONObject extraJson = new JSONObject();
// Place all the information obtained by the third-party APP akip in the extraJson.params field in the Json format
JSONObject paramsData = new JSONObject();
paramsData.put("openid", openid);
// TODO ...
extraJson.put("params", paramsData.toString());
// Get the data brought to the game by transparent transmission, and put it in the game_data field
extraJson.put("game_data", gameData);
// Write extraJson data into the callback data structure
loginWakeupRet.extraJson = extraJson.toString();
// Call the data back to MSDKCore for subsequent judgments of account inconsistency and team information, etc.
IT.onPluginRetCallback(MSDKObserverID.MSDK_PLATFORM_WAKE_UP, loginWakeupRet, loginWakeupRet.seqID);
}
} else {
MSDKLog.e("Garena notifyReceiveIntent is null ");
}
} catch (Exception e) {
MSDKLog.e("Garena notifyReceiveIntent error : " + e.getMessage());
}
}
}
If you need to develop the account inconsistency function, you need to fill in channelOpenID
in addition to seqID
, channel
and channelID
fields, and can optionally fill in pluginData
.
[info] For details, please refer to Demo code
3.Only provide account inconsistency function
This function has no special example. Please refer to the second demo code. Just don't fill the extraJson field.
2.2 iOS platform
2.2.1 Class implementation rule description
Account inconsistency and third-party channel parameter transparent transmission need to first configure life cycle monitoring. For details, please refer to Life Cycle Processing
In MSDKApplicationDelegate
, monitor the openURL
function, and add the third-party information processing logic.
- File name rule:
MSDKApplicationDelegate + channel
, such asMSDKApplicationDelegate+Garena.mm
- Class name rule:
MSDKApplicationDelegate (channel)
, such as:MSDKApplicationDelegate (Garena)
2.1.2 Callback field description
As for the callback function description,, please refer to Client plugin development rules
observerID
callback function IDkObserverIDWakeUp
is used to return the login status information or transparently transmitted parameter information when the game is launched via a third-party channel
ret
return structure- Must be
InnerLoginPluginRet
data structure - If you only develop the third-party channel parameter transparent transmission function, you only need to fill in
seqID
,channel
,channelID
andextraJson
inInnerLoginPluginRet
. Don't fill inchannelOpenID
andpluginData
fields . - If you need to develop the account inconsistency function, you need to fill in
channelOpenID
in addition toseqID
,channel
andchannelID
fields, and can optionally fill inpluginData
. If you need to transparently transmit the parameters of the third-party channel, you only need to fill inextraJson
in Json format.
- Must be
2.2.3 Code example
Common logic code
- (BOOL)garena_application:(UIApplication *_Nullable)application openURL:(nonnull NSURL *)url options:(nonnull NSDictionary *)options {
// TODO get Garena feature information from url
...
// Determine whether it is a Garena APP akip and is a non-login request
if(fromGarena) {
// Handle the information carried by the third-party channel
[self parseMediaTagNameByUrl:url];
}
// The swizzle mechanism must return the call method itself
return [self garena_application:application openURL:url options:options];
}
- (BOOL)garena_application:(UIApplication *_Nullable)application openURL:(NSURL *_Nullable)url sourceApplication:(NSString *_Nullable)sourceApplication annotation:(id _Nullable)annotation {
// TODO get Garena feature information from url
...
// Determine whether it is a Garena APP akip and is a non-login request
if(fromGarena) {
// Handle the information carried by the third-party channel
[self parseMediaTagNameByUrl:url];
}
// The swizzle mechanism must return the call method itself
return [self garena_application:application openURL:url sourceApplication:sourceApplication annotation:annotation];
}
1.Only provide third-party channel parameter transparent transmission function
- (void)parseMediaTagNameByUrl:(NSURL *)url {
// TODO Get Garena parameter information from URL
...
// Assemble callback data
InnerLoginPluginRet wakeupRet;
wakeupRet.seqID = MSDK::CreateSequenceId();
// channel channelID is a required parameter
wakeupRet.channelID = MSDK_GARENA_CHANNEL_ID;
wakeupRet.channel = MSDK_GARENA_CHANNEL;
// Assemble the data extraJson transparently transmitted to the game
MSDKJsonManager extraJson;
// Place all the information obtained by the third-party APP akip in the extraJson.params field in the Json format
extraJson.PutIfAbsent("params", [params UTF8String]);
// Get the data brought to the game by transparent transmission, and put it in the game_data field
extraJson.PutIfAbsent("game_data", [mediaTagNameString UTF8String]);
// Write extraJson data into the callback data structure
std::string extraStr(extraJson);
wakeupRet.extraJson = extraStr;
// Call the data back to MSDKCore for subsequent judgments of account inconsistency and team information, etc.
MSDKInnerObserverHolder<InnerLoginPluginRet>::CommitToTaskQueue(wakeupRet, kObserverIDWakeUp, wakeupRet.seqID);
}
If you don't need to develop an account inconsistency function, you just need to fill in seqID
, channel
, channelID
and extraJson
in InnerLoginPluginRet
. Don't fill in channelOpenID
and pluginData
fields.
[info] For details, please refer to Demo code
2.Provide account inconsistency and third-party channel parameter transparent transmission functions
- (void)parseMediaTagNameByUrl:(NSURL *)url {
// TODO Get Garena parameter information from URL
...
// Assemble callback data
InnerLoginPluginRet wakeupRet;
wakeupRet.seqID = MSDK::CreateSequenceId();
// channel channelID is a required parameter
wakeupRet.channelID = MSDK_GARENA_CHANNEL_ID;
wakeupRet.channel = MSDK_GARENA_CHANNEL;
// If you can get the openid of the current channel user, you can fill in channelOpenID. It can be used to determine in MSDKCore whether the currently logged-in player in the game is the same as the logged-in player in APP
wakeupRet.channelOpenID = openid;
// [Optional] If you can get the same channel data as the data gotten when logging in the game, you can fill in the data in pluginData. These data will be transparently transmitted to the backend for login
MSDKJsonManager pluginData;
pluginData.PutIfAbsent("uid", uid);
pluginData.PutIfAbsent("token", token);
wakeupRet.pluginData = std::string(pluginData);
// Assemble the data extraJson transparently transmitted to the game
MSDKJsonManager extraJson;
// Place all the information obtained by the third-party APP akip in the extraJson.params field in the Json format
extraJson.PutIfAbsent("params", [params UTF8String]);
// Get the data brought to the game by transparent transmission, and put it in the game_data field
extraJson.PutIfAbsent("game_data", [mediaTagNameString UTF8String]);
// Write extraJson data into the callback data structure
wakeupRet.extraJson = std::string(extraJson);
// Call the data back to MSDKCore for subsequent judgments of account inconsistency and team information, etc.
MSDKInnerObserverHolder<InnerLoginPluginRet>::CommitToTaskQueue(wakeupRet, kObserverIDWakeUp, wakeupRet.seqID);
}
If you need to develop the account inconsistency function, you need to fill in channelOpenID
in addition to seqID
, channel
and channelID
fields, and can optionally fill in pluginData
.
[info] For details, please refer to Demo code
3.Only provide account inconsistency function
This function has no special example. Please refer to the second demo code. Just don't fill the extraJson field.
III. Test description
It is recommended that the game should be tested from the following aspects:
3.1 Third-party channel parameter information transparent transmission
1.The current game has no login status. Click the third-party APP player's invitation information to enter the game 2.The current game has the login status. Click the third-party APP player's invitation information to enter the game
3.2 Account inconsistency
1.The current game has no login status. Click the third-party APP player's invitation information to enter the game 2.The current game logs in a third-party channel (such as WeChat) account that is not currently developed. Click the invitation information of the third-party APP (such as Garena) to enter the game 3.The current game login is the third-party channel's account A, and the third-party APP logs in account B. Click the invitation information of the third-party APP (such as Garena) player to enter the game 4.The third-party channel account that the current game logs in is the same as the account that the current third-party APP logs in. Click the invitation information of the third-party APP (such as Garena) player to enter the game
IV. In-depth understanding of the account inconsistency logic
The above information is sufficient for account inconsistency and third-party channel parameter transparent transmission functions. More importantly, the functions need to be tested in detail to meet the specific needs of the game.
Regarding how MSDKCore processes the data transparently transmitted from plugin to Core, you can continue to read the following content.
Logic Description:
[1] The red dashed box means that MSDK will inform the game of the login result (via OnLoginRet callback). This is equivalent to that the game executes the SwitchUser(true) operation. [2] The blue dashed box indicates that through WakeUp (via OnLoginBaseRet callback), MSDK will inform the game of how to further process the data. [3] The green dashed box indicates that, unless there is third-party APP information that needs to be transparently transmitted, no callback will be sent to the game via WakeUp and MSDK will silently process the data.
All rights reserved.