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:
@@ -364,6 +364,43 @@ namespace tysdk
|
||||
UnityBridgeFunc.CleanLinkTmpSnsInfo();
|
||||
}
|
||||
|
||||
public async Task<ChangeLinkResult> ChangeLinkAccount(EAccoutType accoutType, int oldUserId, int newUserId)
|
||||
{
|
||||
var task = TYSDKCallbackManager.Instance.RegisterCallback<ChangeLinkResult>(TimeSpan.FromSeconds(30));
|
||||
UnityBridgeFunc.ChangeLinkAccount(accoutType, oldUserId, newUserId);
|
||||
try
|
||||
{
|
||||
var result = await task;
|
||||
if (result.code == 0)
|
||||
{
|
||||
_accountInfo.AddLinkedAccount(accoutType);
|
||||
_accountInfo.Save();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogWarning($"[TYSdkFacade] Change link account failed: {e}");
|
||||
return new ChangeLinkResult() { code = 1 };
|
||||
}
|
||||
finally
|
||||
{
|
||||
CleanLinkTempSnSInfo();
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeLinkAccountResult(string message)
|
||||
{
|
||||
JObject data = JObject.Parse(message);
|
||||
var result = new ChangeLinkResult()
|
||||
{
|
||||
code = (int)data["code"],
|
||||
userId = (int)data["userId"],
|
||||
msg = (string)data["msg"]
|
||||
};
|
||||
TYSDKCallbackManager.Instance.TryTriggerCallback(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查是否已经绑定
|
||||
/// <returns>
|
||||
|
||||
Reference in New Issue
Block a user