[U] add PlayFab SDK and SNS login improvements
- Add PlayFabSDK as local package dependency - Add PlayFabTool.cs for PlayFab API integration - Implement LoginBySns method in TYSdkFacade - Add Android SNS login support in SDKManager and UnityBridgeFunc - Add Build Android With Debug menu option - Improve exception handling and timeout management 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
"dependencies": {
|
||||
"com.github.skistua.unity-vimeditor": "https://gitee.com/b166er/unity-vimeditor.git",
|
||||
"com.neuecc.unirx": "file:../LocalPackages/com.neuecc.unirx",
|
||||
"com.playfab": "file:../LocalPackages/PlayFabSDK",
|
||||
"com.unity.addressables": "1.22.3",
|
||||
"com.unity.collab-proxy": "2.7.1",
|
||||
"com.unity.ide.rider": "3.0.36",
|
||||
|
||||
@@ -13,6 +13,12 @@
|
||||
"source": "local",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.playfab": {
|
||||
"version": "file:../LocalPackages/PlayFabSDK",
|
||||
"depth": 0,
|
||||
"source": "local",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.thinkingdata.analytics": {
|
||||
"version": "file:com.thinkingdata.analytics@6408c68cf9",
|
||||
"depth": 0,
|
||||
|
||||
@@ -33,6 +33,7 @@ import com.tuyoo.gamesdk.event.EventBus;
|
||||
import com.tuyoo.gamesdk.event.EventConsts;
|
||||
import com.tuyoo.gamesdk.event.data.PayEventData;
|
||||
import com.tuyoo.gamesdk.event.data.WeixinShareData;
|
||||
import com.tuyoo.gamesdk.login.model.SnsInfo;
|
||||
import com.tuyoo.gamesdk.model.InitParam;
|
||||
import com.tuyoo.gamesdk.pay.model.PayType;
|
||||
import com.tuyoo.gamesdk.util.SDKLog;
|
||||
@@ -98,6 +99,7 @@ public class SDKManager {
|
||||
public void callback(int i, String s) {
|
||||
SDKLog.i("SDKCallBack.Login callback: " + i + " \n" + s);
|
||||
parseLoginInfo(i, s);
|
||||
tmpSnsInfo = null;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -127,32 +129,29 @@ public class SDKManager {
|
||||
|
||||
public static void UnityLoginByTokenFun(String token) {
|
||||
SDKLog.i("UnityLoginByTokenFun : " + token);
|
||||
handler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
SDKAPI.getIns().loginByToken(token, mLogin);
|
||||
}
|
||||
});
|
||||
handler.post(() -> SDKAPI.getIns().loginByToken(token, mLogin));
|
||||
}
|
||||
|
||||
public static void UnityLoginBySnsInfo()
|
||||
{
|
||||
if(tmpSnsInfo == null)
|
||||
{
|
||||
UnityPlayer.UnitySendMessage(ConfigManager.UNITY_FACADE_NAME, ConfigManager.LOGIN_CALLBACK_FUNCTION_NAME, "{\"code\":1}}");
|
||||
return;
|
||||
}
|
||||
|
||||
SDKLog.i("UnityLoginBySns : " + tmpSnsInfo);
|
||||
handler.post(() -> SDKAPI.getIns().loginBySnsInfo(tmpSnsInfo, mLogin));
|
||||
}
|
||||
|
||||
public static void UnityGetIdentityFun(String type) {
|
||||
SDKLog.i("UnityGetIdentityFun : " + type);
|
||||
handler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
SDKAPI.getIns().loginByType(type, mLogin);
|
||||
}
|
||||
});
|
||||
handler.post(() -> SDKAPI.getIns().loginByType(type, mLogin));
|
||||
}
|
||||
|
||||
public static void UnityLogin(String type) {
|
||||
SDKLog.i("UnityLogin : " + type);
|
||||
handler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
SDKAPI.getIns().loginByType(type, mLogin);
|
||||
}
|
||||
});
|
||||
handler.post(() -> SDKAPI.getIns().loginByType(type, mLogin));
|
||||
}
|
||||
|
||||
public static void UnityLogOutByChannel(String type) {
|
||||
@@ -160,11 +159,13 @@ public class SDKManager {
|
||||
handler.post(() -> SDKAPI.getIns().logout(type));
|
||||
}
|
||||
|
||||
private static SnsInfo tmpSnsInfo;
|
||||
public static void LinkAccount(String type, String userId)
|
||||
{
|
||||
SDKAPI.getIns().getSnsInfo(type, (snscode, snsInfo, snsmsg) ->{
|
||||
if(snscode == SDKCallBack.CODE_SUCCESS && snsInfo !=null)
|
||||
{
|
||||
tmpSnsInfo = snsInfo;
|
||||
SDKAPI.getIns().bindBySnsId(snsInfo, userId, (bindcode, bindmsg)->{
|
||||
if(bindcode == SDKCallBack.CODE_SUCCESS)
|
||||
{
|
||||
|
||||
@@ -153,24 +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));
|
||||
@@ -193,7 +193,7 @@ namespace tysdk
|
||||
Debug.LogWarning($"[TYSdkFacade] Login failed: {e}");
|
||||
return new LoginInfo(){isSuccess = false};
|
||||
}
|
||||
#endif
|
||||
// #endif
|
||||
}
|
||||
|
||||
public async Task<LoginInfo> LoginByToken()
|
||||
@@ -220,6 +220,31 @@ namespace tysdk
|
||||
return new LoginInfo() { isSuccess = false };
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<LoginInfo> LoginBySns()
|
||||
{
|
||||
var accoutInfo = AccountInfo.GetSavedAccoutInfo();
|
||||
if (accoutInfo == null) return new LoginInfo();
|
||||
|
||||
var task = TYSDKCallbackManager.Instance.RegisterCallback<LoginInfo>(TimeSpan.FromSeconds(30));
|
||||
|
||||
UnityBridgeFunc.UnityLoginByTokenFun(accoutInfo.token);
|
||||
|
||||
try
|
||||
{
|
||||
var loginInfo = await task;
|
||||
if (loginInfo.isSuccess)
|
||||
{
|
||||
_accountInfo.Save();
|
||||
}
|
||||
return loginInfo;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogWarning($"[TYSdkFacade] Login by token failed: {e}");
|
||||
return new LoginInfo() { isSuccess = false };
|
||||
}
|
||||
}
|
||||
|
||||
public void LoginResult(string json)
|
||||
{
|
||||
@@ -285,7 +310,7 @@ namespace tysdk
|
||||
if (_accountInfo == null) return new LinkResult(){ code = 1};
|
||||
if (_accountInfo.linkedAccout.Contains(accoutType)) return new LinkResult(){ code = 0};
|
||||
|
||||
var task = TYSDKCallbackManager.Instance.RegisterCallback<LinkResult>();
|
||||
var task = TYSDKCallbackManager.Instance.RegisterCallback<LinkResult>(TimeSpan.FromMinutes(1));
|
||||
UnityBridgeFunc.LinkAccount(accoutType);
|
||||
|
||||
try
|
||||
|
||||
@@ -17,6 +17,9 @@ namespace tysdk
|
||||
|
||||
//登录
|
||||
public static void UnityLoginByTokenFun(string token){}
|
||||
|
||||
public static void UnityLoginBySnsInfoFun() { }
|
||||
|
||||
public static void UnityLogin(EAccoutType accoutType){}
|
||||
public static void LinkAccount(EAccoutType accoutType){}
|
||||
public static void UnlinkAccount(EAccoutType accoutType){}
|
||||
@@ -54,6 +57,7 @@ namespace tysdk
|
||||
|
||||
public static void FBShareLink(string title, string content, string url) { }
|
||||
public static void MessengerShareLink(string title, string content, string url) { }
|
||||
|
||||
|
||||
#elif UNITY_ANDROID
|
||||
|
||||
@@ -88,6 +92,14 @@ namespace tysdk
|
||||
}
|
||||
}
|
||||
|
||||
public static void UnityLoginBySnsInfoFun()
|
||||
{
|
||||
using(var sdkManager = new AndroidJavaClass(SDK_CLASS))
|
||||
{
|
||||
sdkManager.CallStatic("UnityLoginBySnsInfo");
|
||||
}
|
||||
}
|
||||
|
||||
public static void UnityLogin(EAccoutType accoutType)
|
||||
{
|
||||
using(var sdkManager = new AndroidJavaClass(SDK_CLASS))
|
||||
|
||||
Reference in New Issue
Block a user