- 重构iOS构建参数,添加调试构建选项 - 实现iOS调试构建菜单项,支持开发选项和调试连接 - 修复Android SDKManager中的snsInfo临时存储逻辑 - 添加清理临时snsInfo的方法实现 - 在iOS接口中添加登录类型存储和sns信息重新登录功能 - 重构账号绑定逻辑,统一处理不同平台的绑定流程 - 添加绑定失败时的登出回调处理 - 更新UnityBridgeFunc中的原生接口绑定 - 在测试脚本中添加初始化时清理临时sns信息
155 lines
4.2 KiB
C#
155 lines
4.2 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using tysdk;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class UnbindTest : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private Text message;
|
|
[SerializeField]
|
|
private Button cleanBtn;
|
|
|
|
[SerializeField]
|
|
private Button initBtn;
|
|
|
|
[SerializeField]
|
|
private Dropdown accoutTypeDropdown;
|
|
|
|
[SerializeField]
|
|
private Button loginBtn;
|
|
|
|
[SerializeField]
|
|
private Button logoutBtn;
|
|
|
|
[SerializeField]
|
|
private Button getSnsBtn;
|
|
|
|
[SerializeField]
|
|
private Button checkSnsBtn;
|
|
|
|
[SerializeField]
|
|
private Button bindBtn;
|
|
|
|
[SerializeField]
|
|
private Button unbindBtn;
|
|
|
|
private EAccoutType accoutType;
|
|
|
|
private const string Cls = "com.unity3d.player.SnsTest";
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
Screen.sleepTimeout = SleepTimeout.NeverSleep;
|
|
message.text = string.Empty;
|
|
accoutType = (EAccoutType)accoutTypeDropdown.value;
|
|
|
|
cleanBtn.onClick.AddListener(() => message.text = string.Empty);
|
|
initBtn.onClick.AddListener(Init);
|
|
accoutTypeDropdown.onValueChanged.AddListener((index) =>
|
|
{
|
|
accoutType = (EAccoutType)index;
|
|
message.text += $"[Account Type] {accoutType.ToString()}\r\n";
|
|
}); loginBtn.onClick.AddListener(OnLogin);
|
|
logoutBtn.onClick.AddListener(OnLogout);
|
|
getSnsBtn.onClick.AddListener(OnGetSns);
|
|
checkSnsBtn.onClick.AddListener(OnCheckSns);
|
|
bindBtn.onClick.AddListener(OnBind);
|
|
unbindBtn.onClick.AddListener(OnUnbind);
|
|
Debug.Log("========== Init =============");
|
|
TYSdkFacade.Instance.Init();
|
|
Debug.Log($"AccoutType {accoutType}");
|
|
}
|
|
|
|
private void Init()
|
|
{
|
|
UnityBridgeFunc.UnityResetServerUrl("https://128-hwsfsdk-sdk-test01.qijihdhk.com");
|
|
TYSdkFacade.Instance.CleanLinkTempSnSInfo();
|
|
}
|
|
|
|
private void OnLogout()
|
|
{
|
|
Debug.Log("========== Logout =============");
|
|
TYSdkFacade.Instance.Logout();
|
|
}
|
|
|
|
private LoginInfo loginInfo;
|
|
private async void OnLogin()
|
|
{
|
|
Debug.Log("========== Login =============");
|
|
message.text += $"Login {accoutType}\r\n";
|
|
var info = await TYSdkFacade.Instance.Login(accoutType);
|
|
message.text = $"Login Success {info.isSuccess}\r\n";
|
|
if(info.isSuccess)
|
|
{
|
|
loginInfo = info;
|
|
}
|
|
}
|
|
|
|
private void OnGetSns()
|
|
{
|
|
Debug.Log("========== Get SNS =============");
|
|
using var t = new AndroidJavaClass(Cls);
|
|
t.CallStatic("GetSns", accoutType.ToString());
|
|
}
|
|
|
|
private async void OnCheckSns()
|
|
{
|
|
try
|
|
{
|
|
Debug.Log("========== Login by sns =============");
|
|
message.text += $"Login {accoutType}\r\n";
|
|
var info = await TYSdkFacade.Instance.LoginBySns();
|
|
message.text = $"sns Login Success {info.isSuccess}\r\n";
|
|
if(info.isSuccess)
|
|
{
|
|
loginInfo = info;
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Debug.LogException(e);
|
|
}
|
|
}
|
|
|
|
private async void OnBind()
|
|
{
|
|
try
|
|
{
|
|
Debug.Log("========== Bind =============");
|
|
var linkResult = await TYSdkFacade.Instance.LinkAccount(accoutType);
|
|
Debug.Log($"Bind Result Code:{linkResult.code}, UserId:{linkResult.userId}, bindInfo:{linkResult.bindInfo}");
|
|
if(linkResult.code == -1)
|
|
{
|
|
var info = await PlayFabTool.GetPFPlayerInfoBySDKId(linkResult.userId, "6DC6D");
|
|
Debug.Log(info?.ToString() ?? "[UnbindTest::OnBind] info is null");
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Debug.LogException(e);
|
|
}
|
|
}
|
|
|
|
public void BindCallback(string message)
|
|
{
|
|
|
|
}
|
|
|
|
private void OnUnbind()
|
|
{
|
|
using (var t = new AndroidJavaClass(Cls))
|
|
{
|
|
t.CallStatic("Unbind");
|
|
}
|
|
}
|
|
|
|
public void UnbindCallback(string message)
|
|
{
|
|
|
|
}
|
|
}
|