enhance ChangeLinkAccount functionality
- Added LoginTypeToBindType function to map login types to binding types. - Updated ChangeLinkAccount method to handle account linking and unbinding with appropriate error handling. - Ensured proper messaging for success and failure cases during account changes. - Cleaned temporary SNS information after account change attempts.
This commit is contained in:
@@ -266,6 +266,41 @@ public class SDKManager {
|
||||
tmpSnsInfo = null;
|
||||
}
|
||||
|
||||
public static void ChangeLinkAccount(String type, int oldUserId, int newUserId)
|
||||
{
|
||||
if(tmpSnsInfo == null)
|
||||
{
|
||||
String msg = "{\"code\":1, \"userId\": 0, \"msg\": \"tmpSnsInfo is null\"}";
|
||||
UnityPlayer.UnitySendMessage(ConfigManager.UNITY_FACADE_NAME, ConfigManager.CHANGELINK_CALLBACK_FUNCTION_NAME, msg);
|
||||
return;
|
||||
}
|
||||
|
||||
SDKAPI.getIns().unbindBySnsId(tmpSnsInfo, String.valueOf(oldUserId), (unbindCode, unbindMsg) -> {
|
||||
Log.i(TAG, "unbindBySnsId code: " + unbindCode + " msg: " + unbindMsg);
|
||||
if(unbindCode == SDKCallBack.CODE_SUCCESS)
|
||||
{
|
||||
SDKAPI.getIns().bindBySnsId(tmpSnsInfo, String.valueOf(newUserId), (bindCode, bindMsg) -> {
|
||||
Log.i(TAG, "bindBySnsId code: " + bindCode + " msg: " + bindMsg);
|
||||
if(bindCode == SDKCallBack.CODE_SUCCESS)
|
||||
{
|
||||
String msg = "{\"code\":0, \"userId\": " + newUserId + ", \"msg\": \"success\"}";
|
||||
UnityPlayer.UnitySendMessage(ConfigManager.UNITY_FACADE_NAME, ConfigManager.CHANGELINK_CALLBACK_FUNCTION_NAME, msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
String msg = String.format("{\"code\":-1, \"userId\": 0, \"msg\": \"%s\"}", bindMsg);
|
||||
UnityPlayer.UnitySendMessage(ConfigManager.UNITY_FACADE_NAME, ConfigManager.CHANGELINK_CALLBACK_FUNCTION_NAME, msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
String msg = String.format("{\"code\":1, \"userId\": 0, \"msg\": \"%s\"}", unbindMsg);
|
||||
UnityPlayer.UnitySendMessage(ConfigManager.UNITY_FACADE_NAME, ConfigManager.CHANGELINK_CALLBACK_FUNCTION_NAME, msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void LinkCheck(String type)
|
||||
{
|
||||
SDKAPI.getIns().getSnsInfo(type, (code, snsInfo, msg) -> {
|
||||
|
||||
Reference in New Issue
Block a user