refactor(tysdk): 重构SDK登录和绑定功能

- 重构iOS构建参数,添加调试构建选项
- 实现iOS调试构建菜单项,支持开发选项和调试连接
- 修复Android SDKManager中的snsInfo临时存储逻辑
- 添加清理临时snsInfo的方法实现
- 在iOS接口中添加登录类型存储和sns信息重新登录功能
- 重构账号绑定逻辑,统一处理不同平台的绑定流程
- 添加绑定失败时的登出回调处理
- 更新UnityBridgeFunc中的原生接口绑定
- 在测试脚本中添加初始化时清理临时sns信息
This commit is contained in:
2026-01-07 15:08:04 +08:00
parent cb2ff22a89
commit 4d12bdf0ec
6 changed files with 208 additions and 59 deletions

View File

@@ -387,6 +387,10 @@ namespace tysdk
TYSDKCallbackManager.Instance.TryTriggerCallback(result);
}
#endif
public void CleanLinkTempSnSInfo()
{
UnityBridgeFunc.CleanLinkTmpSnsInfo();
}
/// <summary>
/// 检查是否已经绑定

View File

@@ -21,6 +21,10 @@ namespace tysdk
public static string UnityLoginBySnsInfoFun() => null;
public static void UnityLogin(EAccoutType accoutType){}
public static void CleanLinkTmpSnsInfo() { }
public static void LinkAccount(EAccoutType accoutType){}
public static void UnlinkAccount(EAccoutType accoutType){}
public static void LinkCheck(EAccoutType accoutType){}
@@ -135,6 +139,16 @@ namespace tysdk
}
}
public static void CleanLinkTmpSnsInfo(){
using(var sdkManager = new AndroidJavaClass(SDK_CLASS))
{
using(var activityCls = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
{
sdkManager.CallStatic("CleanLinkTmpSnsInfo");
}
}
}
public static void UnlinkAccount(EAccoutType accoutType)
{
using(var sdkManager = new AndroidJavaClass(SDK_CLASS))
@@ -247,6 +261,23 @@ namespace tysdk
[DllImport("__Internal")]
public static extern void UnityLoginByTokenFun(string token);
[DllImport("__Internal")]
private static extern IntPtr UnityLoginBySnsInfo();
public static string UnityLoginBySnsInfoFun()
{
IntPtr ptr = UnityLoginBySnsInfo();
if (ptr == IntPtr.Zero)
{
return string.Empty;
}
// Convert C string to C# string
string result = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(ptr);
return result ?? string.Empty;
}
public static void UnityLogin(EAccoutType accoutType)
{
switch (accoutType)
@@ -317,16 +348,18 @@ namespace tysdk
public static void LinkAccount(EAccoutType accoutType)
{
var userId = TYSdkFacade.TYAccountInfo.userId;
switch (accoutType)
{
case EAccoutType.hwGoogle:
LinkGoogle();
LinkGoogle(userId);
break;
case EAccoutType.hwFacebook:
LinkFacebook();
LinkFacebook(userId);
break;
case EAccoutType.Apple:
LinkApple();
LinkApple(userId);
break;
}
}
@@ -344,11 +377,11 @@ namespace tysdk
}
}
[DllImport("__Internal")] private static extern void LinkGoogle();
[DllImport("__Internal")] private static extern void LinkGoogle(int userId);
[DllImport("__Internal")] private static extern void UnlinkGoogle();
[DllImport("__Internal")] private static extern void LinkFacebook();
[DllImport("__Internal")] private static extern void LinkFacebook(int userId);
[DllImport("__Internal")] private static extern void UnlinkFacebook();
[DllImport("__Internal")] private static extern void LinkApple();
[DllImport("__Internal")] private static extern void LinkApple(int userId);
[DllImport("__Internal")] private static extern void UnlinkApple();
public static void LinkCheck(EAccoutType accoutType)
@@ -368,6 +401,8 @@ namespace tysdk
}
}
[DllImport("__Internal")] public static extern void CleanLinkTmpSnsInfo();
[DllImport("__Internal")] private static extern void IsLinkedGoogle();
[DllImport("__Internal")] private static extern void IsLinkedFacebook();
[DllImport("__Internal")] private static extern void IsLinkedApple();