enhance ChangeLinkAccount functionality
- Added LoginTypeToBindType function to map login types to binding types. - Updated ChangeLinkAccount method to handle account linking and unbinding with appropriate error handling. - Ensured proper messaging for success and failure cases during account changes. - Cleaned temporary SNS information after account change attempts.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using tysdk;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
@@ -28,13 +29,17 @@ public class UnbindTest : MonoBehaviour
|
||||
private Button getSnsBtn;
|
||||
|
||||
[SerializeField]
|
||||
private Button checkSnsBtn;
|
||||
private Button rmSnsBtn;
|
||||
|
||||
|
||||
[SerializeField]
|
||||
private Button loginBySns;
|
||||
|
||||
[SerializeField]
|
||||
private Button bindBtn;
|
||||
|
||||
[SerializeField]
|
||||
private Button unbindBtn;
|
||||
private Button changeBindBtn;
|
||||
|
||||
private EAccoutType accoutType;
|
||||
|
||||
@@ -56,9 +61,10 @@ public class UnbindTest : MonoBehaviour
|
||||
}); loginBtn.onClick.AddListener(OnLogin);
|
||||
logoutBtn.onClick.AddListener(OnLogout);
|
||||
getSnsBtn.onClick.AddListener(OnGetSns);
|
||||
checkSnsBtn.onClick.AddListener(OnCheckSns);
|
||||
rmSnsBtn.onClick.AddListener(OnRmSns);
|
||||
loginBySns.onClick.AddListener(OnLoginBySns);
|
||||
bindBtn.onClick.AddListener(OnBind);
|
||||
unbindBtn.onClick.AddListener(OnUnbind);
|
||||
changeBindBtn.onClick.AddListener(OnChangeBind);
|
||||
Debug.Log("========== Init =============");
|
||||
TYSdkFacade.Instance.Init();
|
||||
Debug.Log($"AccoutType {accoutType}");
|
||||
@@ -96,7 +102,14 @@ public class UnbindTest : MonoBehaviour
|
||||
t.CallStatic("GetSns", accoutType.ToString());
|
||||
}
|
||||
|
||||
private async void OnCheckSns()
|
||||
private void OnRmSns()
|
||||
{
|
||||
Debug.Log("========== Get SNS =============");
|
||||
using var t = new AndroidJavaClass(Cls);
|
||||
t.CallStatic("RmSns") ;
|
||||
}
|
||||
|
||||
private async void OnLoginBySns()
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -115,6 +128,7 @@ public class UnbindTest : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
private int buserId;
|
||||
private async void OnBind()
|
||||
{
|
||||
try
|
||||
@@ -126,6 +140,7 @@ public class UnbindTest : MonoBehaviour
|
||||
{
|
||||
var info = await PlayFabTool.GetPFPlayerInfoBySDKId(linkResult.userId, "6DC6D");
|
||||
Debug.Log(info?.ToString() ?? "[UnbindTest::OnBind] info is null");
|
||||
buserId = linkResult.userId;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -134,21 +149,17 @@ public class UnbindTest : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
public void BindCallback(string message)
|
||||
private async void OnChangeBind()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void OnUnbind()
|
||||
{
|
||||
using (var t = new AndroidJavaClass(Cls))
|
||||
try
|
||||
{
|
||||
t.CallStatic("Unbind");
|
||||
Debug.Log("========== Change Bind =============");
|
||||
var result = await TYSdkFacade.Instance.ChangeLinkAccount(accoutType, buserId, loginInfo.userId);
|
||||
Debug.Log($"Change Bind Result Code:{result.code}, UserId:{result.userId}, msg:{result.msg}");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void UnbindCallback(string message)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user