[M] change sns link function

This commit is contained in:
2025-12-25 15:41:48 +08:00
parent 8cc0a67f03
commit 58a29b0335
8 changed files with 106 additions and 26 deletions

View File

@@ -273,16 +273,16 @@ namespace tysdk
#if UNITY_EDITOR
public async Task<bool> LinkAccount(EAccoutType accoutType)
public async Task<LinkResult> LinkAccount(EAccoutType accoutType)
{
await Task.Delay(300);
return true;
return new LinkResult(){code = 1};
}
#elif UNITY_IOS || UNITY_ANDROID
public async Task<bool> LinkAccount(EAccoutType accoutType)
public async Task<LinkResult> LinkAccount(EAccoutType accoutType)
{
if (_accountInfo == null) return false;
if (_accountInfo.linkedAccout.Contains(accoutType)) return true;
if (_accountInfo == null) return new LinkResult(){ code = 1};
if (_accountInfo.linkedAccout.Contains(accoutType)) return new LinkResult(){ code = 0};
var task = TYSDKCallbackManager.Instance.RegisterCallback<LinkResult>();
UnityBridgeFunc.LinkAccount(accoutType);
@@ -290,7 +290,7 @@ namespace tysdk
try
{
var result = await task;
if (result.isSuccess)
if (result.code == 0)
{
if (_accountInfo == null)
_accountInfo = AccountInfo.GetSavedAccoutInfo();
@@ -301,20 +301,22 @@ namespace tysdk
_accountInfo.Save();
}
}
return result.isSuccess;
return result;
}
catch (Exception e)
{
Debug.LogWarning($"[TYSdkFacade] Link account failed: {e}");
return false;
return new LinkResult() { code = 1 };
}
}
public void LinkAccoutResult(string codestr)
public void LinkAccoutResult(string message)
{
JObject data = new JObject(message);
var result = new LinkResult()
{
isSuccess = codestr == "1"
code = data["code"].Value<int>(),
userId = data["userId"].Value<int>()
};
TYSDKCallbackManager.Instance.TryTriggerCallback(result);

View File

@@ -12,7 +12,6 @@ namespace tysdk
Apple,
none
}
public class LoginInfo
{
@@ -25,7 +24,13 @@ namespace tysdk
public class LinkResult
{
public bool isSuccess;
// 0: success, 1: fail, -1 exists
public int code;
// when success and fail userId is current user
// when exists userId is 0
public int userId;
// not none when exists
public string bindInfo;
}
public class LinkCheckInfo