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:
2026-03-30 21:49:14 +08:00
parent 9f5151c54c
commit 6866b7fca9
9 changed files with 694 additions and 60 deletions

View File

@@ -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>