[M] fix SNS login and JSON syntax errors

- Fix extra closing brace in JSON error callbacks (SDKManager.java)
- Enable SNS type return from UnityLoginBySnsInfo for proper account channel tracking
- Update LoginBySns to use returned SNS type for linked account management
- Re-enable editor mode login for testing

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-30 20:24:13 +08:00
parent aa5ce1ff5a
commit 053bdf70a2
3 changed files with 38 additions and 32 deletions

View File

@@ -153,26 +153,24 @@ namespace tysdk
public async Task<LoginInfo> Login(EAccoutType accoutType)
{
// #if UNITY_EDITOR
// await Task.Yield();
// var deviceId = UnityEngine.Device.SystemInfo.deviceUniqueIdentifier.Split('-')[0].Substring(0, 8);
//
// var userId = (int)ulong.Parse(deviceId, System.Globalization.NumberStyles.HexNumber);
//
// _accountInfo = new AccountInfo()
// {
// userId = userId,
// };
//
// return new LoginInfo()
// {
// isSuccess = true,
// userId = userId
// };
//
// #elif UNITY_ANDROID || UNITY_IOS
#if UNITY_EDITOR
await Task.Yield();
var deviceId = UnityEngine.Device.SystemInfo.deviceUniqueIdentifier.Split('-')[0].Substring(0, 8);
var userId = (int)ulong.Parse(deviceId, System.Globalization.NumberStyles.HexNumber);
_accountInfo = new AccountInfo()
{
userId = userId,
};
return new LoginInfo()
{
isSuccess = true,
userId = userId
};
#elif UNITY_ANDROID || UNITY_IOS
var task = TYSDKCallbackManager.Instance.RegisterCallback<LoginInfo>(TimeSpan.FromSeconds(30));
UnityBridgeFunc.UnityLogin(accoutType);
@@ -193,7 +191,7 @@ namespace tysdk
Debug.LogWarning($"[TYSdkFacade] Login failed: {e}");
return new LoginInfo(){isSuccess = false};
}
// #endif
#endif
}
public async Task<LoginInfo> LoginByToken()
@@ -223,18 +221,23 @@ namespace tysdk
public async Task<LoginInfo> LoginBySns()
{
var accoutInfo = AccountInfo.GetSavedAccoutInfo();
if (accoutInfo == null) return new LoginInfo();
var accountInfo = AccountInfo.GetSavedAccoutInfo();
if (accountInfo == null) return new LoginInfo();
var task = TYSDKCallbackManager.Instance.RegisterCallback<LoginInfo>(TimeSpan.FromSeconds(30));
UnityBridgeFunc.UnityLoginByTokenFun(accoutInfo.token);
var snsType = UnityBridgeFunc.UnityLoginBySnsInfoFun();
try
{
var loginInfo = await task;
if (loginInfo.isSuccess)
{
if (Enum.TryParse<EAccoutType>(snsType, out var accountType))
{
_accountInfo.channel = accountType;
}
_accountInfo.AddLinkedAccount(accountType);
_accountInfo.Save();
}
return loginInfo;