[F] Link [A] signout
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using asap.core;
|
||||
using Newtonsoft.Json.Linq;
|
||||
@@ -24,7 +26,8 @@ namespace tysdk
|
||||
private static Dictionary<string, EAccoutType> accoutTypeMap = new Dictionary<string, EAccoutType>(){
|
||||
{"google", EAccoutType.hwGoogle},
|
||||
{"fb", EAccoutType.hwFacebook},
|
||||
{"tyGuest", EAccoutType.hwGuest}
|
||||
{"tyGuest", EAccoutType.hwGuest},
|
||||
{"ios13", EAccoutType.Apple}
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -262,6 +265,59 @@ namespace tysdk
|
||||
UnityBridgeFunc.SetGaUserInfo(strUserId);
|
||||
}
|
||||
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public async Task<bool> LinkAccount(EAccoutType accoutType)
|
||||
{
|
||||
await Task.Delay(300);
|
||||
return true;
|
||||
}
|
||||
#elif UNITY_IOS
|
||||
|
||||
public async Task<bool> LinkAccount(EAccoutType accoutType)
|
||||
{
|
||||
if (_accountInfo == null) return false;
|
||||
if( _accountInfo.linkedAccout.Contains(accoutType)) return true;
|
||||
|
||||
var taskSource = new TaskCompletionSource<LinkResult>();
|
||||
callbacks.Add("LinkAccoutResult", (ITYSdkCallback callback) =>
|
||||
{
|
||||
taskSource.SetResult((LinkResult)callback);
|
||||
});
|
||||
|
||||
UnityBridgeFunc.LinkAccount(accoutType);
|
||||
|
||||
var result = await taskSource.Task;
|
||||
if (result.isSuccess)
|
||||
{
|
||||
var savedInfo = AccountInfo.GetSavedAccoutInfo();
|
||||
if(savedInfo != null)
|
||||
{
|
||||
savedInfo.AddLinkedAccount(accoutType);
|
||||
savedInfo.Save();
|
||||
_accountInfo = savedInfo;
|
||||
}
|
||||
}
|
||||
|
||||
return result.isSuccess;
|
||||
}
|
||||
|
||||
public void LinkAccoutResult(string codestr)
|
||||
{
|
||||
var result = new LinkResult()
|
||||
{
|
||||
isSuccess = codestr == "1"
|
||||
};
|
||||
|
||||
if (callbacks.TryGetValue("LinkAccoutResult", out var action))
|
||||
{
|
||||
action.Invoke(result);
|
||||
callbacks.Remove("LoginResult");
|
||||
}
|
||||
}
|
||||
|
||||
#elif UNITY_ANDROID
|
||||
|
||||
public async Task<bool> LinkAccount(EAccoutType accoutType)
|
||||
{
|
||||
if (_accountInfo == null) return false;
|
||||
@@ -280,6 +336,8 @@ namespace tysdk
|
||||
return result.isSuccess;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// 检查是否已经绑定
|
||||
/// <returns>
|
||||
@@ -327,5 +385,91 @@ namespace tysdk
|
||||
callbacks.Remove("CheckLinkResult");
|
||||
}
|
||||
}
|
||||
|
||||
public void Signout()
|
||||
{
|
||||
List<string> list = new List<string>();
|
||||
string defaultTyurl = "https://128-hwsfsdk-sdk-online01.qijihdhk.com";
|
||||
|
||||
IConfig config = GContext.container.Resolve<IConfig>();
|
||||
var tyurl = config.Get<string>("AGG_SERVER", defaultTyurl);
|
||||
|
||||
|
||||
string tycs = tyurl == defaultTyurl ?
|
||||
"https://hwcsh.tygameworld.com /template/appCancel/note.html"
|
||||
:
|
||||
"https://customermanage-feature-test-web-test.tuyougame.cn/appCancel/note.html";
|
||||
|
||||
string sdkurl = $"sdkurl={tyurl}";
|
||||
list.Add(sdkurl);
|
||||
|
||||
string appid = "appid=20587";
|
||||
list.Add(appid);
|
||||
|
||||
#if UNITY_ANDROID
|
||||
string clientid = "Android_5.00_tyGuest,facebook.googleplay.0-hall20587.googleplay.FishingMaster";
|
||||
#elif UNITY_IOS
|
||||
string clientid = "IOS_5.00_tyGuest,facebook,appStore.appStore.0-hall20587.appStore.FishingMaster";
|
||||
#endif
|
||||
list.Add($"clientid={clientid}");
|
||||
|
||||
string uid = $"uid={_accountInfo.userId}";
|
||||
list.Add(uid);
|
||||
|
||||
string roleid = "roleid=0";
|
||||
list.Add(roleid);
|
||||
|
||||
string gameid = "gameid=20587";
|
||||
list.Add(gameid);
|
||||
|
||||
string cloudid = "cloudid=128";
|
||||
list.Add(cloudid);
|
||||
|
||||
string gamename = "gamename=FishingTravel";
|
||||
list.Add(gamename);
|
||||
|
||||
string certification = "certification=0";
|
||||
list.Add(certification);
|
||||
|
||||
string ischannel = "ischannel=1";
|
||||
list.Add(ischannel);
|
||||
|
||||
string tysdktoken = $"tysdktoken={_accountInfo.token}";
|
||||
list.Add(tysdktoken);
|
||||
|
||||
list.Sort();
|
||||
|
||||
string listStr = string.Join("&", list.ToArray());
|
||||
string sign = listStr +
|
||||
"csh-api-6dfa879490a249be9fbc92e97e4d898d-api-csh";
|
||||
//对sign进行MD5加密
|
||||
string signMd5 = CalculateMD5Hash(sign);
|
||||
string url = $"{tycs}?{listStr}&sign={signMd5}&isAbroad=1";
|
||||
Debug.Log($"[TYSdkFacade:Signout] url \n{url}");
|
||||
Application.OpenURL(url);
|
||||
}
|
||||
|
||||
private string CalculateMD5Hash(string input)
|
||||
{
|
||||
// Create a new instance of the MD5CryptoServiceProvider object.
|
||||
MD5 md5Hasher = MD5.Create();
|
||||
|
||||
// Convert the input string to a byte array and compute the hash.
|
||||
byte[] data = md5Hasher.ComputeHash(Encoding.Default.GetBytes(input));
|
||||
|
||||
// Create a new Stringbuilder to collect the bytes
|
||||
// and create a string.
|
||||
StringBuilder sBuilder = new StringBuilder();
|
||||
|
||||
// Loop through each byte of the hashed data
|
||||
// and format each one as a hexadecimal string.
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
{
|
||||
sBuilder.Append(data[i].ToString("x2"));
|
||||
}
|
||||
|
||||
// Return the hexadecimal string.
|
||||
return sBuilder.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,9 @@ namespace tysdk
|
||||
hwGoogle,
|
||||
hwFacebook,
|
||||
hwGuest,
|
||||
#if UNITY_IOS
|
||||
Apple,
|
||||
#endif
|
||||
none
|
||||
}
|
||||
|
||||
@@ -23,6 +26,11 @@ namespace tysdk
|
||||
public int code;
|
||||
}
|
||||
|
||||
public class LinkResult : ITYSdkCallback
|
||||
{
|
||||
public bool isSuccess;
|
||||
}
|
||||
|
||||
public class LinkCheckInfo : ITYSdkCallback
|
||||
{
|
||||
public int code;
|
||||
|
||||
@@ -220,6 +220,9 @@ namespace tysdk
|
||||
case EAccoutType.hwGuest:
|
||||
UnityLoginByGuest();
|
||||
break;
|
||||
case EAccoutType.Apple:
|
||||
UnityLoginByApple();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,6 +235,9 @@ namespace tysdk
|
||||
[DllImport("__Internal")]
|
||||
public static extern void UnityLoginByFacebook();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
public static extern void UnityLoginByApple();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
public static extern void UnityGetIdentityFun(string type);
|
||||
|
||||
@@ -251,6 +257,9 @@ namespace tysdk
|
||||
case EAccoutType.hwGuest:
|
||||
UnityLogoutGuest();
|
||||
break;
|
||||
case EAccoutType.Apple:
|
||||
UnityLogoutApple();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,6 +272,9 @@ namespace tysdk
|
||||
[DllImport("__Internal")]
|
||||
private static extern void UnityLogoutGuest();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void UnityLogoutApple();
|
||||
|
||||
public static void LinkAccount(EAccoutType accoutType)
|
||||
{
|
||||
switch (accoutType)
|
||||
@@ -273,6 +285,9 @@ namespace tysdk
|
||||
case EAccoutType.hwFacebook:
|
||||
LinkFacebook();
|
||||
break;
|
||||
case EAccoutType.Apple:
|
||||
LinkApple();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -293,6 +308,8 @@ namespace tysdk
|
||||
[DllImport("__Internal")] private static extern void UnlinkGoogle();
|
||||
[DllImport("__Internal")] private static extern void LinkFacebook();
|
||||
[DllImport("__Internal")] private static extern void UnlinkFacebook();
|
||||
[DllImport("__Internal")] private static extern void LinkApple();
|
||||
[DllImport("__Internal")] private static extern void UnlinkApple();
|
||||
|
||||
public static void LinkCheck(EAccoutType accoutType)
|
||||
{
|
||||
@@ -304,11 +321,16 @@ namespace tysdk
|
||||
case EAccoutType.hwFacebook:
|
||||
IsLinkedFacebook();
|
||||
break;
|
||||
|
||||
case EAccoutType.Apple:
|
||||
IsLinkedApple();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("__Internal")] private static extern void IsLinkedGoogle();
|
||||
[DllImport("__Internal")] private static extern void IsLinkedFacebook();
|
||||
[DllImport("__Internal")] private static extern void IsLinkedApple();
|
||||
|
||||
|
||||
//支付
|
||||
|
||||
Reference in New Issue
Block a user