备份CatanBuilding瘦身独立工程
This commit is contained in:
18
Packages/tysdk/Runtime/AppRequestReview.cs
Normal file
18
Packages/tysdk/Runtime/AppRequestReview.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using UnityEngine;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace tysdk
|
||||
{
|
||||
public static class AppRequestReview
|
||||
{
|
||||
#if UNITY_EDITOR || UNITY_ANDROID
|
||||
public static void RequestReview(string customReviewURL)
|
||||
{
|
||||
tysdk.UnityBridgeFunc.Review();
|
||||
}
|
||||
#elif UNITY_IOS
|
||||
[DllImport("__Internal")]
|
||||
public static extern void RequestReview(string customReviewURL);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
11
Packages/tysdk/Runtime/AppRequestReview.cs.meta
Normal file
11
Packages/tysdk/Runtime/AppRequestReview.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b4630fc5c78457748a2f763ac5168df6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
491
Packages/tysdk/Runtime/TYSdkFacade.cs
Normal file
491
Packages/tysdk/Runtime/TYSdkFacade.cs
Normal file
@@ -0,0 +1,491 @@
|
||||
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;
|
||||
using UnityEngine;
|
||||
|
||||
namespace tysdk
|
||||
{
|
||||
public partial class TYSdkFacade : MonoBehaviour
|
||||
{
|
||||
public class AccountInfo
|
||||
{
|
||||
public int userId;
|
||||
public string token;
|
||||
public string jwtToken;
|
||||
public string strUserId => userId.ToString();
|
||||
public HashSet<EAccoutType> linkedAccout = new HashSet<EAccoutType>();
|
||||
public EAccoutType channel {get; set;}
|
||||
public string userName;
|
||||
public string avatar;
|
||||
|
||||
private const string KEY_ACCOUNT_INFO = "KEY_ACCOUNT_INFO";
|
||||
|
||||
public void AddLinkedAccount(EAccoutType accoutType)
|
||||
{
|
||||
if (!linkedAccout.Contains(accoutType))
|
||||
{
|
||||
linkedAccout.Add(accoutType);
|
||||
}
|
||||
}
|
||||
|
||||
private static Dictionary<string, EAccoutType> accoutTypeMap = new Dictionary<string, EAccoutType>(){
|
||||
{"google", EAccoutType.hwGoogle},
|
||||
{"fb", EAccoutType.hwFacebook},
|
||||
{"tyGuest", EAccoutType.hwGuest},
|
||||
{"ios13", EAccoutType.Apple}
|
||||
};
|
||||
|
||||
private static EAccoutType ConvertAccoutType(string accountType)
|
||||
{
|
||||
if (accoutTypeMap.ContainsKey(accountType))
|
||||
{
|
||||
return accoutTypeMap[accountType];
|
||||
}
|
||||
return (EAccoutType)Enum.Parse(typeof(EAccoutType), accountType);
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
JObject jInfo = new JObject();
|
||||
jInfo["channel"] = channel.ToString();
|
||||
jInfo["token"] = token;
|
||||
jInfo["userId"] = userId;
|
||||
jInfo["userName"] = userName;
|
||||
jInfo["avatar"] = avatar;
|
||||
jInfo["jwtToken"] = jwtToken;
|
||||
jInfo["linkedAccout"] = string.Join(",", linkedAccout.Select(x => x.ToString()));
|
||||
PlayerPrefs.SetString(KEY_ACCOUNT_INFO, jInfo.ToString());
|
||||
}
|
||||
|
||||
public static void Remove()
|
||||
{
|
||||
PlayerPrefs.DeleteKey(KEY_ACCOUNT_INFO);
|
||||
}
|
||||
|
||||
public static AccountInfo GetSavedAccoutInfo()
|
||||
{
|
||||
if (PlayerPrefs.HasKey(KEY_ACCOUNT_INFO))
|
||||
{
|
||||
var jInfo = JObject.Parse(PlayerPrefs.GetString(KEY_ACCOUNT_INFO));
|
||||
var accountInfo = new AccountInfo()
|
||||
{
|
||||
userId = (int)jInfo["userId"],
|
||||
token = (string)jInfo["token"],
|
||||
channel = ConvertAccoutType((string)jInfo["channel"]),
|
||||
jwtToken = (string)jInfo["jwtToken"],
|
||||
linkedAccout = jInfo["linkedAccout"].ToString().Split(',').Select(x => ConvertAccoutType(x)).ToHashSet()
|
||||
};
|
||||
|
||||
if(jInfo.TryGetValue("userName", out var userName))
|
||||
{
|
||||
accountInfo.userName = (string) userName;
|
||||
}
|
||||
|
||||
if(jInfo.TryGetValue("avatar", out var avatar))
|
||||
{
|
||||
accountInfo.avatar = (string)avatar;
|
||||
}
|
||||
|
||||
return accountInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static AccountInfo _accountInfo;
|
||||
public static AccountInfo TYAccountInfo => _accountInfo;
|
||||
|
||||
private static IDictionary<string, Action<ITYSdkCallback>> callbacks = new Dictionary<string, Action<ITYSdkCallback>>();
|
||||
|
||||
private static TYSdkFacade _instance;
|
||||
public static TYSdkFacade Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = new GameObject("TYSdkFacade").AddComponent<TYSdkFacade>();
|
||||
DontDestroyOnLoad(_instance.gameObject);
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
UnityBridgeFunc.InitSDK();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*================================================
|
||||
|
||||
_ _
|
||||
/ \ ___ ___ ___ _ _ _ __ | |_
|
||||
/ _ \ / __/ __/ _ \| | | | '_ \| __|
|
||||
/ ___ \ (_| (_| (_) | |_| | | | | |_
|
||||
/_/ \_\___\___\___/ \__,_|_| |_|\__|
|
||||
|
||||
=================================================*/
|
||||
|
||||
|
||||
public static bool IsLoggedIn => _accountInfo != null;
|
||||
|
||||
public void Logout()
|
||||
{
|
||||
UnityEngine.Debug.Log("Logout");
|
||||
if(_accountInfo != null)
|
||||
{
|
||||
UnityBridgeFunc.UnityLogOutByChannel(_accountInfo.channel);
|
||||
}
|
||||
|
||||
_accountInfo = null;
|
||||
AccountInfo.Remove();
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
var taskSource = new TaskCompletionSource<LoginInfo>();
|
||||
callbacks.Add("LoginResult", (ITYSdkCallback callback) =>
|
||||
{
|
||||
taskSource.SetResult((LoginInfo)callback);
|
||||
});
|
||||
|
||||
UnityBridgeFunc.UnityLogin(accoutType);
|
||||
|
||||
var loginInfo = await taskSource.Task;
|
||||
if(loginInfo.isSuccess)
|
||||
{
|
||||
_accountInfo.channel = accoutType;
|
||||
_accountInfo.AddLinkedAccount(accoutType);
|
||||
_accountInfo.Save();
|
||||
}
|
||||
return loginInfo;
|
||||
#endif
|
||||
}
|
||||
|
||||
public async Task<LoginInfo> LoginByToken()
|
||||
{
|
||||
var accoutInfo = AccountInfo.GetSavedAccoutInfo();
|
||||
if(accoutInfo == null) return new LoginInfo();
|
||||
|
||||
var taskSource = new TaskCompletionSource<LoginInfo>();
|
||||
callbacks.Add("LoginResult", (ITYSdkCallback callback) =>
|
||||
{
|
||||
taskSource.SetResult((LoginInfo)callback);
|
||||
});
|
||||
|
||||
UnityBridgeFunc.UnityLoginByTokenFun(accoutInfo.token);
|
||||
|
||||
var loginInfo = await taskSource.Task;
|
||||
if(loginInfo.isSuccess)
|
||||
{
|
||||
_accountInfo.Save();
|
||||
}
|
||||
return loginInfo;
|
||||
}
|
||||
|
||||
public void LoginResult(string json)
|
||||
{
|
||||
Debug.Log("[TYSdkFacade] Login callback:");
|
||||
var result = new LoginInfo();
|
||||
var data = JObject.Parse(json);
|
||||
var code = (int)data["code"];
|
||||
result.code = code;
|
||||
|
||||
if (code == 0)
|
||||
{
|
||||
var loginData = data["respObj"]["result"];
|
||||
|
||||
var userId = (int)loginData["userId"];
|
||||
var token = (string)loginData["token"];
|
||||
var jwtToken = (string)loginData["jwttoken"];
|
||||
|
||||
var savedInfo = AccountInfo.GetSavedAccoutInfo();
|
||||
if(savedInfo == null || savedInfo.userId != userId)
|
||||
{
|
||||
_accountInfo = new AccountInfo()
|
||||
{
|
||||
userId = (int)loginData["userId"],
|
||||
userName = (string)loginData["userName"],
|
||||
avatar = (string)loginData["purl"],
|
||||
token = (string)loginData["token"],
|
||||
jwtToken = (string)loginData["jwttoken"],
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
savedInfo.token = token;
|
||||
savedInfo.jwtToken = jwtToken;
|
||||
_accountInfo = savedInfo;
|
||||
}
|
||||
|
||||
result.isSuccess = true;
|
||||
result.userId = _accountInfo.userId;
|
||||
SetUserInfo();
|
||||
}
|
||||
|
||||
if (callbacks.TryGetValue("LoginResult", out var action))
|
||||
{
|
||||
action.Invoke(result);
|
||||
callbacks.Remove("LoginResult");
|
||||
}
|
||||
}
|
||||
|
||||
private void SetUserInfo()
|
||||
{
|
||||
if (_accountInfo == null) return;
|
||||
var strUserId = _accountInfo.strUserId;
|
||||
|
||||
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)
|
||||
{
|
||||
if(_accountInfo == null)
|
||||
_accountInfo = AccountInfo.GetSavedAccoutInfo();
|
||||
|
||||
if(_accountInfo != null)
|
||||
{
|
||||
_accountInfo.AddLinkedAccount(accoutType);
|
||||
_accountInfo.Save();
|
||||
}
|
||||
}
|
||||
|
||||
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("LinkAccoutResult");
|
||||
}
|
||||
}
|
||||
|
||||
#elif UNITY_ANDROID
|
||||
|
||||
public async Task<bool> LinkAccount(EAccoutType accoutType)
|
||||
{
|
||||
if (_accountInfo == null) return false;
|
||||
if( _accountInfo.linkedAccout.Contains(accoutType)) return true;
|
||||
|
||||
var taskSource = new TaskCompletionSource<LoginInfo>();
|
||||
callbacks.Add("LoginResult", (ITYSdkCallback callback) =>
|
||||
{
|
||||
taskSource.SetResult((LoginInfo)callback);
|
||||
});
|
||||
|
||||
UnityBridgeFunc.LinkAccount(accoutType);
|
||||
|
||||
var result = await taskSource.Task;
|
||||
if (result.isSuccess)
|
||||
{
|
||||
if(_accountInfo == null)
|
||||
_accountInfo = AccountInfo.GetSavedAccoutInfo();
|
||||
|
||||
if(_accountInfo != null)
|
||||
{
|
||||
_accountInfo.AddLinkedAccount(accoutType);
|
||||
_accountInfo.Save();
|
||||
}
|
||||
}
|
||||
|
||||
return result.isSuccess;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// 检查是否已经绑定
|
||||
/// <returns>
|
||||
/// 1 已经绑定
|
||||
/// 0 未绑定
|
||||
/// -1 失败
|
||||
/// </returns>
|
||||
/// </summary>
|
||||
public async Task<bool> LinkCheck(EAccoutType accoutType)
|
||||
{
|
||||
if (_accountInfo == null) return false;
|
||||
if( _accountInfo.linkedAccout.Contains(accoutType)) return true;
|
||||
|
||||
var taskSource = new TaskCompletionSource<LinkCheckInfo>();
|
||||
callbacks.Add("CheckLinkResult", (ITYSdkCallback callback) =>
|
||||
{
|
||||
taskSource.SetResult((LinkCheckInfo)callback);
|
||||
});
|
||||
|
||||
UnityBridgeFunc.LinkCheck(accoutType);
|
||||
|
||||
var code = (await taskSource.Task).code;
|
||||
|
||||
if (code == 1 && !_accountInfo.linkedAccout.Contains(accoutType))
|
||||
{
|
||||
_accountInfo.linkedAccout.Add(accoutType);
|
||||
_accountInfo.Save();
|
||||
}
|
||||
|
||||
if(code == -1)
|
||||
{
|
||||
Debug.LogError("[TYSdkFacade] CheckLinkResult error");
|
||||
}
|
||||
|
||||
return code == 1;
|
||||
}
|
||||
|
||||
public void CheckLinkResult(string codestr)
|
||||
{
|
||||
if (callbacks.TryGetValue("CheckLinkResult", out var action))
|
||||
{
|
||||
var result = new LinkCheckInfo();
|
||||
result.code = int.Parse(codestr);
|
||||
action.Invoke(result);
|
||||
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&lan=en";
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Packages/tysdk/Runtime/TYSdkFacade.cs.meta
Normal file
11
Packages/tysdk/Runtime/TYSdkFacade.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: db12db58fbcc54046aa4dac203cd4971
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
49
Packages/tysdk/Runtime/TYSdkFacade_ATT.cs
Normal file
49
Packages/tysdk/Runtime/TYSdkFacade_ATT.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace tysdk
|
||||
{
|
||||
public partial class TYSdkFacade : MonoBehaviour
|
||||
{
|
||||
/*================================================
|
||||
|
||||
_ _____ _____
|
||||
/ \|_ _|_ _|
|
||||
/ _ \ | | | |
|
||||
/ ___ \| | | |
|
||||
/_/ \_\_| |_|
|
||||
|
||||
=================================================*/
|
||||
|
||||
public bool IsAttAccepted()
|
||||
{
|
||||
return UnityBridgeFunc.GetATT() == 1;
|
||||
}
|
||||
|
||||
public async Task<ATTInfo> RequestATT()
|
||||
{
|
||||
#if UNITY_EDITOR || UNITY_ANDROID
|
||||
await Task.Yield();
|
||||
|
||||
return new ATTInfo(){isAccepted = true};
|
||||
#elif UNITY_IOS
|
||||
var taskSource = new TaskCompletionSource<ATTInfo>();
|
||||
callbacks.Add("RequestATT", (ITYSdkCallback callback) =>
|
||||
{
|
||||
taskSource.SetResult((ATTInfo)callback);
|
||||
});
|
||||
UnityBridgeFunc.RequestATT();
|
||||
return await taskSource.Task;
|
||||
#endif
|
||||
}
|
||||
|
||||
public void RequestATTResult(string r)
|
||||
{
|
||||
if (callbacks.TryGetValue("RequestATT", out var action))
|
||||
{
|
||||
action.Invoke(new ATTInfo(){isAccepted = r == "1"});
|
||||
callbacks.Remove("RequestATT");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Packages/tysdk/Runtime/TYSdkFacade_ATT.cs.meta
Normal file
3
Packages/tysdk/Runtime/TYSdkFacade_ATT.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8f92075f5f98490ca94ae4984ac0aa21
|
||||
timeCreated: 1722855901
|
||||
160
Packages/tysdk/Runtime/TYSdkFacade_GA.cs
Normal file
160
Packages/tysdk/Runtime/TYSdkFacade_GA.cs
Normal file
@@ -0,0 +1,160 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace tysdk
|
||||
{
|
||||
public partial class TYSdkFacade : MonoBehaviour
|
||||
{
|
||||
/*================================================
|
||||
|
||||
_____ _ _____ _
|
||||
| ____|_ _____ _ __ | |_ |_ _| __ __ _ ___| | __
|
||||
| _| \ \ / / _ \ '_ \| __| | || '__/ _` |/ __| |/ /
|
||||
| |___ \ V / __/ | | | |_ | || | | (_| | (__| <
|
||||
|_____| \_/ \___|_| |_|\__| |_||_| \__,_|\___|_|\_\
|
||||
|
||||
=================================================*/
|
||||
|
||||
public void EventTrack(int type, string name, string content)
|
||||
{
|
||||
#if UNITY_IOS || UNITY_ANDROID
|
||||
UnityBridgeFunc.GAReportParams(type, name, content);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
public enum GATrackType
|
||||
{
|
||||
GA_TRACK = 1, //默认类型
|
||||
GA_CION = 2, //金流相关事件
|
||||
GA_PAY = 3, //支付相关事件
|
||||
GA_GAME = 4, //游戏行为
|
||||
GA_LOGIN = 5, //登录注册相关事件
|
||||
GA_PUSH = 6, //推送相关事件
|
||||
GA_ADBOX = 7, //adbox相关事件
|
||||
GA_PREFORMANCE = 8, //性能上报相关事件
|
||||
GA_SDK = 9, //SDK相关事件
|
||||
GA_ABTest = 10, //abtest相关事件
|
||||
}
|
||||
|
||||
/*
|
||||
public class GAEvent : IDisposable
|
||||
{
|
||||
|
||||
private GATrackType eventType;
|
||||
private string eventName;
|
||||
bool AFSend = true;
|
||||
private JObject content = new JObject();
|
||||
public static Dictionary<string, string> extraContent = new Dictionary<string, string>();
|
||||
|
||||
public GAEvent(GATrackType eventType, string eventName, bool AFSend = true)
|
||||
{
|
||||
this.eventType = eventType;
|
||||
this.eventName = eventName;
|
||||
this.AFSend = AFSend;
|
||||
}
|
||||
|
||||
public GAEvent AddContent(string key, string value)
|
||||
{
|
||||
content[key] = value;
|
||||
return this; }
|
||||
|
||||
public GAEvent AddContent(string key, int value)
|
||||
{
|
||||
content[key] = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GAEvent AddContent(string key, bool value)
|
||||
{
|
||||
content[key] = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GAEvent AddContent(string key, float value)
|
||||
{
|
||||
content[key] = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GAEvent AddContent(string key, JToken value)
|
||||
{
|
||||
content[key] = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
foreach (var item in extraContent)
|
||||
{
|
||||
content[item.Key] = item.Value;
|
||||
}
|
||||
|
||||
string msg = content.ToString();
|
||||
if (msg == String.Empty) return;
|
||||
|
||||
if (AFSend)
|
||||
{
|
||||
SendAfEvent(eventType,eventName,msg);
|
||||
}
|
||||
|
||||
TYSdkFacade.Instance.EventTrack((int)eventType, eventName, msg);
|
||||
|
||||
content.RemoveAll();
|
||||
}
|
||||
|
||||
private void SendAfEvent(GATrackType type,string eventName,string logMessage)
|
||||
{
|
||||
Dictionary<string, string> eventValues = new Dictionary<string, string>();
|
||||
eventValues.Add("GA_TYPE", type.ToString());
|
||||
eventValues.Add(eventName, logMessage);
|
||||
AppsFlyer.sendEvent(AFInAppEvents.GA, eventValues);
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
*GA_TRACK(默认类型)
|
||||
*GA_CION(金流相关事件)
|
||||
*GA_PAY(支付相关事件)
|
||||
*GA_GAME(游戏行为)
|
||||
*GA_LOGIN(登录注册相关事件)
|
||||
*GA_PUSH(推送相关事件)
|
||||
*GA_ADBOX(adbox相关事件)
|
||||
*GA_PREFORMANCE(性能上报相关事件)
|
||||
*GA_SDK(SDK相关事件)
|
||||
*GA_ABTest(abtest相关事件)
|
||||
*GA_PROFILE(设置用户特征
|
||||
*/
|
||||
//TOD SDK
|
||||
/*
|
||||
public static GAEvent TackEvent(string eventName, bool afSend = true)
|
||||
{
|
||||
return new GAEvent(GATrackType.GA_TRACK, eventName, afSend);
|
||||
}
|
||||
|
||||
public static GAEvent PushEvent(string eventName, bool afSend = true)
|
||||
{
|
||||
return new GAEvent(GATrackType.GA_PUSH, eventName, afSend);
|
||||
}
|
||||
|
||||
public static GAEvent CionEvent(string eventName, bool afSend = true)
|
||||
{
|
||||
return new GAEvent(GATrackType.GA_CION, eventName, afSend);
|
||||
}
|
||||
|
||||
public static GAEvent PayEvent(string eventName, bool afSend = true)
|
||||
{
|
||||
return new GAEvent(GATrackType.GA_PAY, eventName, afSend);
|
||||
}
|
||||
|
||||
public static GAEvent GameEvent(string eventName, bool afSend = true)
|
||||
{
|
||||
return new GAEvent(GATrackType.GA_GAME, eventName, afSend);
|
||||
}
|
||||
|
||||
public static GAEvent LoginEvent(string eventName, bool afSend = true)
|
||||
{
|
||||
return new GAEvent(GATrackType.GA_LOGIN, eventName, afSend);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
3
Packages/tysdk/Runtime/TYSdkFacade_GA.cs.meta
Normal file
3
Packages/tysdk/Runtime/TYSdkFacade_GA.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 18459dcf8d5a40dc80ffae5333a6b0c9
|
||||
timeCreated: 1722855439
|
||||
161
Packages/tysdk/Runtime/TYSdkFacade_Pay.cs
Normal file
161
Packages/tysdk/Runtime/TYSdkFacade_Pay.cs
Normal file
@@ -0,0 +1,161 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace tysdk
|
||||
{
|
||||
public partial class TYSdkFacade : MonoBehaviour
|
||||
{
|
||||
/*================================================
|
||||
|
||||
____ _
|
||||
| _ \ __ _ _ _ _ __ ___ ___ _ __ | |_
|
||||
| |_) / _` | | | | '_ ` _ \ / _ \ '_ \| __|
|
||||
| __/ (_| | |_| | | | | | | __/ | | | |_
|
||||
|_| \__,_|\__, |_| |_| |_|\___|_| |_|\__|
|
||||
|___/
|
||||
=================================================*/
|
||||
|
||||
//public async Task<PaymentInfo> Pay(string prodId, string prodPrice, string prodName, int count, string pType, string price_amount_micros =null)
|
||||
public async Task<PaymentInfo> Pay(SKUDetail prod, int count, float usdprice, JObject purchaseInfo)
|
||||
{
|
||||
if (!IsLoggedIn) return new PaymentInfo() { code = "-1", msg = "未登录" };
|
||||
|
||||
var orderId = System.Guid.NewGuid().ToString();
|
||||
|
||||
if(purchaseInfo == null)
|
||||
purchaseInfo = new JObject();
|
||||
|
||||
string extraInfo = purchaseInfo.ToString(Newtonsoft.Json.Formatting.None);
|
||||
//to base64
|
||||
extraInfo = Convert.ToBase64String(Encoding.UTF8.GetBytes(extraInfo));
|
||||
Debug.Log("[TYSdk] extraInfo: " + extraInfo);
|
||||
var prodId = prod.ProdID;
|
||||
var prodPrice = usdprice.ToString();
|
||||
var prodName = prod.title;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
|
||||
await Task.Yield();
|
||||
var result = new PaymentInfo()
|
||||
{
|
||||
code = "0",
|
||||
msg = "success",
|
||||
count = count,
|
||||
orderId = orderId,
|
||||
productId = prodId,
|
||||
price = prodPrice
|
||||
};
|
||||
|
||||
|
||||
return result;
|
||||
#elif UNITY_ANDROID
|
||||
|
||||
var pType = "googleiab.global.app";
|
||||
|
||||
var taskSource = new TaskCompletionSource<PaymentInfo>();
|
||||
callbacks.Add("PayResult", (ITYSdkCallback callback) =>
|
||||
{
|
||||
taskSource.SetResult((PaymentInfo)callback);
|
||||
});
|
||||
|
||||
//UnityBridgeFunc.UnityKnow(prodId, prodName, count.ToString(), orderId, extraInfo);
|
||||
UnityBridgeFunc.UnityKnowNew(prodId, prodPrice, prodName, count.ToString(), orderId, extraInfo,pType);
|
||||
|
||||
var result = await taskSource.Task;
|
||||
result.count = count;
|
||||
result.orderId = orderId;
|
||||
result.productId = prodId;
|
||||
result.price = prodPrice;
|
||||
return result;
|
||||
|
||||
#elif UNITY_IOS
|
||||
var taskSource = new TaskCompletionSource<PaymentInfo>();
|
||||
callbacks.Add("PayResult", (ITYSdkCallback callback) =>
|
||||
{
|
||||
taskSource.SetResult((PaymentInfo)callback);
|
||||
});
|
||||
UnityBridgeFunc.UnityKnow(_accountInfo.strUserId, prodId, prodPrice, prodName, count.ToString(), orderId, extraInfo);
|
||||
|
||||
var result = await taskSource.Task;
|
||||
result.count = count;
|
||||
result.orderId = orderId;
|
||||
result.productId = prodId;
|
||||
result.price = prodPrice;
|
||||
return result;
|
||||
#endif
|
||||
}
|
||||
|
||||
//支付的回调
|
||||
public void PayResult(string json)
|
||||
{
|
||||
Debug.Log("[TYSdkFacade] pay callback:" + json);
|
||||
var jresult = JObject.Parse(json);
|
||||
var result = new PaymentInfo();
|
||||
result.code = jresult["code"].ToString();
|
||||
result.msg = jresult["errStr"].ToString();
|
||||
|
||||
if (callbacks.TryGetValue("PayResult", out var action))
|
||||
{
|
||||
action.Invoke(result);
|
||||
callbacks.Remove("PayResult");
|
||||
}
|
||||
}
|
||||
|
||||
// Get Pay list
|
||||
public async Task<ProductListInfo> GetSKUList()
|
||||
{
|
||||
if (!IsLoggedIn) return new ProductListInfo() { code = -1, msg = "未登录" };
|
||||
|
||||
#if UNITY_EDITOR
|
||||
await Task.Yield();
|
||||
|
||||
var result = new ProductListInfo();
|
||||
return result;
|
||||
#elif UNITY_ANDROID || UNITY_IOS
|
||||
var taskSource = new TaskCompletionSource<ProductListInfo>();
|
||||
callbacks.Add("SKUListResult", (ITYSdkCallback callback) =>
|
||||
{
|
||||
taskSource.SetResult((ProductListInfo) callback);
|
||||
});
|
||||
UnityBridgeFunc.GetSKUList();
|
||||
var result = await taskSource.Task;
|
||||
return result;
|
||||
#endif
|
||||
}
|
||||
|
||||
//商品列表的回调
|
||||
public void SKUListResult(string json)
|
||||
{
|
||||
Debug.Log("[TYSdkFacade] GetSKUList callback");
|
||||
var jresult = JObject.Parse(json);
|
||||
int code = int.Parse(jresult["code"].ToString());
|
||||
var result = new ProductListInfo();
|
||||
if (code == 0)
|
||||
{
|
||||
string productStr = jresult["respObj"].ToString();
|
||||
result.code = code;
|
||||
#if UNITY_ANDROID && !UNITY_EDITOR
|
||||
var jsonObjList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<SKUDetail>>(productStr);
|
||||
result.products = jsonObjList;
|
||||
#elif UNITY_IOS && !UNITY_EDITOR
|
||||
result.ReadSKUFromJson(productStr);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (callbacks.TryGetValue("SKUListResult", out var action))
|
||||
{
|
||||
action.Invoke(result);
|
||||
callbacks.Remove("SKUListResult");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
3
Packages/tysdk/Runtime/TYSdkFacade_Pay.cs.meta
Normal file
3
Packages/tysdk/Runtime/TYSdkFacade_Pay.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 41b6dc16dbab43388317bf9ff032cdca
|
||||
timeCreated: 1722855703
|
||||
141
Packages/tysdk/Runtime/TYSdkModel.cs
Normal file
141
Packages/tysdk/Runtime/TYSdkModel.cs
Normal file
@@ -0,0 +1,141 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace tysdk
|
||||
{
|
||||
public enum EAccoutType
|
||||
{
|
||||
hwGoogle,
|
||||
hwFacebook,
|
||||
hwGuest,
|
||||
Apple,
|
||||
none
|
||||
}
|
||||
|
||||
public interface ITYSdkCallback { }
|
||||
|
||||
public class LoginInfo : ITYSdkCallback
|
||||
{
|
||||
public bool isSuccess;
|
||||
public int userId;
|
||||
public string StrUserId => userId.ToString();
|
||||
public string msg;
|
||||
public int code;
|
||||
}
|
||||
|
||||
public class LinkResult : ITYSdkCallback
|
||||
{
|
||||
public bool isSuccess;
|
||||
}
|
||||
|
||||
public class LinkCheckInfo : ITYSdkCallback
|
||||
{
|
||||
public int code;
|
||||
}
|
||||
|
||||
public class PaymentInfo : ITYSdkCallback
|
||||
{
|
||||
public bool isSuccessFromSdk => code == "0";
|
||||
public bool isSuccess => isSuccessFromSdk && confirmed;
|
||||
private bool confirmed {get; set;} = false;
|
||||
public int count;
|
||||
public string orderId;
|
||||
public string productId;
|
||||
public string price;
|
||||
|
||||
public string code;
|
||||
public string msg;
|
||||
|
||||
public bool Check(string orderId, string productId)
|
||||
{
|
||||
confirmed = orderId == this.orderId && productId == this.productId;
|
||||
|
||||
if(!confirmed)
|
||||
UnityEngine.Debug.LogWarning("[TYSdk Pay] order not confirmed");
|
||||
return confirmed;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Newtonsoft.Json.JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
|
||||
public class ProductListInfo: ITYSdkCallback
|
||||
{
|
||||
public int code = 1;
|
||||
public string msg = string.Empty;
|
||||
public List<SKUDetail> products;
|
||||
|
||||
#if UNITY_IOS && !UNITY_EDITOR
|
||||
public void ReadSKUFromJson(string json)
|
||||
{
|
||||
var prodList = Newtonsoft.Json.Linq.JArray.Parse(json).Select(x => {
|
||||
return new SKUDetail() {
|
||||
price = x["price"].ToString(),
|
||||
productId = x["productId"].ToString(),
|
||||
price_currency_code = x["LocaleCurrencyCode"].ToString(),
|
||||
localeCurrencySymbol = x["localeCurrencySymbol"].ToString(),
|
||||
localizedDescription = x["localizedDescription"].ToString(),
|
||||
title = x["localizedTitle"].ToString(),
|
||||
ProdKey = x["productIdentifier"].ToString()
|
||||
};
|
||||
}).ToList();
|
||||
products = prodList;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#if UNITY_IOS
|
||||
public class SKUDetail
|
||||
{
|
||||
public string price;
|
||||
public string productId;
|
||||
public string price_currency_code;
|
||||
public string localeCurrencySymbol;
|
||||
public string localizedDescription;
|
||||
public string title;
|
||||
public string type;
|
||||
|
||||
public string ProdPriceStr => price;
|
||||
public float ProdPrice => float.Parse(price);
|
||||
public string ProdID => productId;
|
||||
public string ProdKey;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Newtonsoft.Json.JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
#else
|
||||
public class SKUDetail
|
||||
{
|
||||
public string description;
|
||||
public string ourProductId;
|
||||
public string price;
|
||||
public string price_amount_micros;
|
||||
public string price_currency_code;
|
||||
public string productId;
|
||||
public string title;
|
||||
public string type;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Newtonsoft.Json.JsonConvert.SerializeObject(this);
|
||||
}
|
||||
|
||||
public string ProdPriceStr => price;
|
||||
public float ProdPrice => float.Parse(price_amount_micros) / 1000000;
|
||||
public string ProdID => ourProductId;
|
||||
public string ProdKey => productId;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
public class ATTInfo : ITYSdkCallback
|
||||
{
|
||||
public bool isAccepted;
|
||||
}
|
||||
}
|
||||
11
Packages/tysdk/Runtime/TYSdkModel.cs.meta
Normal file
11
Packages/tysdk/Runtime/TYSdkModel.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b94c8e87cc23b4053a4cbf592ff14db3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
397
Packages/tysdk/Runtime/UnityBridgeFunc.cs
Normal file
397
Packages/tysdk/Runtime/UnityBridgeFunc.cs
Normal file
@@ -0,0 +1,397 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine;
|
||||
|
||||
namespace tysdk
|
||||
{
|
||||
|
||||
public static class UnityBridgeFunc
|
||||
{
|
||||
|
||||
#if UNITY_EDITOR
|
||||
//初始化sdk
|
||||
public static void InitSDK(){}
|
||||
|
||||
//更新登录支付域名
|
||||
public static void UnityResetServerUrl(string url){}
|
||||
|
||||
//登录
|
||||
public static void UnityLoginByTokenFun(string token){}
|
||||
public static void UnityLogin(EAccoutType accoutType){}
|
||||
public static void LinkAccount(EAccoutType accoutType){}
|
||||
public static void UnlinkAccount(EAccoutType accoutType){}
|
||||
public static void LinkCheck(EAccoutType accoutType){}
|
||||
|
||||
public static void UnityGetIdentityFun(string type){}
|
||||
|
||||
public static void UnityLogOutByChannel(EAccoutType accoutType){}
|
||||
//支付new
|
||||
public static void UnityKnowNew(string productId, string productPrice, string productName,
|
||||
string productCount, string prodorderId, string appInfo, string pType) { }
|
||||
|
||||
//支付
|
||||
|
||||
public static void UnityKnow(String productId, String productName, String productCount,
|
||||
String prodorderId, String appInfo) {}
|
||||
|
||||
//获取商品列表
|
||||
public static void GetSKUList() { }
|
||||
|
||||
//打点
|
||||
public static void SetGaUserInfo(string userId){}
|
||||
|
||||
|
||||
public static void SetGaCommonInfo(string SetGaCommonInfo){}
|
||||
|
||||
public static void GAReportParams(int type, string eventstr, string paramstr){}
|
||||
|
||||
//ATT
|
||||
public static void RequestATT(){}
|
||||
|
||||
public static int GetATT() {return 1;}
|
||||
|
||||
public static void Review() { }
|
||||
|
||||
public static void FBShareLink(string title, string content, string url) { }
|
||||
public static void MessengerShareLink(string title, string content, string url) { }
|
||||
|
||||
#elif UNITY_ANDROID
|
||||
|
||||
private static string SDK_CLASS = "com.unity3d.player.SDKManager";
|
||||
|
||||
//初始化sdk
|
||||
public static void InitSDK(){
|
||||
using(var sdkManager = new AndroidJavaClass(SDK_CLASS))
|
||||
{
|
||||
using(var activityCls = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
|
||||
{
|
||||
var activity = activityCls.GetStatic<AndroidJavaObject>("currentActivity");
|
||||
sdkManager.CallStatic("InitSDK", activity);
|
||||
}
|
||||
}
|
||||
}
|
||||
//更新登录支付域名
|
||||
public static void UnityResetServerUrl(string url)
|
||||
{
|
||||
using(var sdkManager = new AndroidJavaClass(SDK_CLASS))
|
||||
{
|
||||
sdkManager.CallStatic("UnityResetServerUrl", url);
|
||||
}
|
||||
}
|
||||
|
||||
//登录
|
||||
public static void UnityLoginByTokenFun(string token)
|
||||
{
|
||||
using(var sdkManager = new AndroidJavaClass(SDK_CLASS))
|
||||
{
|
||||
sdkManager.CallStatic("UnityLoginByTokenFun", token);
|
||||
}
|
||||
}
|
||||
|
||||
public static void UnityLogin(EAccoutType accoutType)
|
||||
{
|
||||
using(var sdkManager = new AndroidJavaClass(SDK_CLASS))
|
||||
{
|
||||
sdkManager.CallStatic("UnityLogin", accoutType.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public static void UnityGetIdentityFun(string type)
|
||||
{
|
||||
using(var sdkManager = new AndroidJavaClass(SDK_CLASS))
|
||||
{
|
||||
sdkManager.CallStatic("UnityGetIdentityFun", type);
|
||||
}
|
||||
}
|
||||
|
||||
public static void UnityLogOutByChannel(EAccoutType accoutType)
|
||||
{
|
||||
|
||||
using(var sdkManager = new AndroidJavaClass(SDK_CLASS))
|
||||
{
|
||||
sdkManager.CallStatic("UnityLogOutByChannel", accoutType.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public static void LinkAccount(EAccoutType accoutType)
|
||||
{
|
||||
using(var sdkManager = new AndroidJavaClass(SDK_CLASS))
|
||||
{
|
||||
string userId = TYSdkFacade.TYAccountInfo.strUserId;
|
||||
sdkManager.CallStatic("LinkAccount", accoutType.ToString(), userId);
|
||||
}
|
||||
}
|
||||
|
||||
public static void UnlinkAccount(EAccoutType accoutType)
|
||||
{
|
||||
using(var sdkManager = new AndroidJavaClass(SDK_CLASS))
|
||||
{
|
||||
sdkManager.CallStatic("UnlinkAccount", accoutType.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public static void LinkCheck(EAccoutType accoutType)
|
||||
{
|
||||
using(var sdkManager = new AndroidJavaClass(SDK_CLASS))
|
||||
{
|
||||
sdkManager.CallStatic("LinkCheck", accoutType.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
//支付new
|
||||
public static void UnityKnowNew(string productId, string productPrice, string productName,
|
||||
string productCount, string prodorderId, string appInfo,string pType)
|
||||
{
|
||||
using(var sdkManager = new AndroidJavaClass(SDK_CLASS))
|
||||
{
|
||||
sdkManager.CallStatic("UnityKnowNew", productId, productPrice, productName,
|
||||
productCount, prodorderId, appInfo,pType);
|
||||
}
|
||||
}
|
||||
|
||||
//支付
|
||||
|
||||
public static void UnityKnow(String productId, String productName, String productCount, String prodorderId, String appInfo)
|
||||
{
|
||||
using(var sdkManager = new AndroidJavaClass(SDK_CLASS))
|
||||
{
|
||||
sdkManager.CallStatic("UnityKnow", productId, productName, productCount, prodorderId, appInfo);
|
||||
}
|
||||
}
|
||||
|
||||
//获取商品列表
|
||||
public static void GetSKUList()
|
||||
{
|
||||
UnityEngine.Debug.Log("UnityBridgeFunc.GetSKUList()");
|
||||
using(var sdkManager = new AndroidJavaClass(SDK_CLASS))
|
||||
{
|
||||
sdkManager.CallStatic("thirdExtend");
|
||||
}
|
||||
}
|
||||
|
||||
//打点
|
||||
public static void SetGaUserInfo(string userId)
|
||||
{
|
||||
using(var sdkManager = new AndroidJavaClass(SDK_CLASS))
|
||||
{
|
||||
sdkManager.CallStatic("SetGaUserInfo", userId);
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetGaCommonInfo(string SetGaCommonInfo)
|
||||
{
|
||||
using(var sdkManager = new AndroidJavaClass(SDK_CLASS))
|
||||
{
|
||||
sdkManager.CallStatic("SetGaCommonInfo", SetGaCommonInfo);
|
||||
}
|
||||
}
|
||||
|
||||
public static void GAReportParams(int type, string eventstr, string paramstr)
|
||||
{
|
||||
using(var sdkManager = new AndroidJavaClass(SDK_CLASS))
|
||||
{
|
||||
sdkManager.CallStatic("GAReportParams", type, eventstr, paramstr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//ATT
|
||||
public static void RequestATT(){}
|
||||
|
||||
public static int GetATT() {return 1;}
|
||||
|
||||
public static void Review()
|
||||
{
|
||||
using(var sdkManager = new AndroidJavaClass(SDK_CLASS))
|
||||
{
|
||||
sdkManager.CallStatic("Review");
|
||||
}
|
||||
}
|
||||
|
||||
public static void FBShareLink(string title, string content, string url)
|
||||
{
|
||||
using(var sdkManager = new AndroidJavaClass(SDK_CLASS))
|
||||
{
|
||||
sdkManager.CallStatic("FBShareLink", title, content, url);
|
||||
}
|
||||
}
|
||||
|
||||
public static void MessengerShareLink(string title, string content, string url)
|
||||
{
|
||||
using(var sdkManager = new AndroidJavaClass(SDK_CLASS))
|
||||
{
|
||||
sdkManager.CallStatic("MessengerShareLink", title, content, url);
|
||||
}
|
||||
}
|
||||
|
||||
#elif UNITY_IOS
|
||||
|
||||
//更新登录支付域名
|
||||
[DllImport("__Internal")]
|
||||
public static extern void UnityResetServerUrl(string url);
|
||||
|
||||
//登录
|
||||
[DllImport("__Internal")]
|
||||
public static extern void UnityLoginByTokenFun(string token);
|
||||
|
||||
public static void UnityLogin(EAccoutType accoutType)
|
||||
{
|
||||
switch (accoutType)
|
||||
{
|
||||
case EAccoutType.hwGoogle:
|
||||
UnityLoginByGoogle();
|
||||
break;
|
||||
case EAccoutType.hwFacebook:
|
||||
UnityLoginByFacebook();
|
||||
break;
|
||||
case EAccoutType.hwGuest:
|
||||
UnityLoginByGuest();
|
||||
break;
|
||||
case EAccoutType.Apple:
|
||||
UnityLoginByApple();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("__Internal")]
|
||||
public static extern void UnityLoginByGuest();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
public static extern void UnityLoginByGoogle();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
public static extern void UnityLoginByFacebook();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
public static extern void UnityLoginByApple();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
public static extern void UnityGetIdentityFun(string type);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
public static extern void UnityLoginOut();
|
||||
|
||||
public static void UnityLogOutByChannel(EAccoutType accoutType)
|
||||
{
|
||||
switch (accoutType)
|
||||
{
|
||||
case EAccoutType.hwGoogle:
|
||||
UnityLogoutGoogle();
|
||||
break;
|
||||
case EAccoutType.hwFacebook:
|
||||
UnityLogoutFacebook();
|
||||
break;
|
||||
case EAccoutType.hwGuest:
|
||||
UnityLogoutGuest();
|
||||
break;
|
||||
case EAccoutType.Apple:
|
||||
UnityLogoutApple();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void UnityLogoutGoogle();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void UnityLogoutFacebook();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void UnityLogoutGuest();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void UnityLogoutApple();
|
||||
|
||||
public static void LinkAccount(EAccoutType accoutType)
|
||||
{
|
||||
switch (accoutType)
|
||||
{
|
||||
case EAccoutType.hwGoogle:
|
||||
LinkGoogle();
|
||||
break;
|
||||
case EAccoutType.hwFacebook:
|
||||
LinkFacebook();
|
||||
break;
|
||||
case EAccoutType.Apple:
|
||||
LinkApple();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static void UnlinkAccount(EAccoutType accoutType)
|
||||
{
|
||||
switch (accoutType)
|
||||
{
|
||||
case EAccoutType.hwGoogle:
|
||||
UnlinkGoogle();
|
||||
break;
|
||||
case EAccoutType.hwFacebook:
|
||||
UnlinkFacebook();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("__Internal")] private static extern void LinkGoogle();
|
||||
[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)
|
||||
{
|
||||
switch (accoutType)
|
||||
{
|
||||
case EAccoutType.hwGoogle:
|
||||
IsLinkedGoogle();
|
||||
break;
|
||||
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();
|
||||
|
||||
|
||||
//支付
|
||||
[DllImport("__Internal")]
|
||||
public static extern void UnityKnow(string userId, string productId, string productPrice, string productName,
|
||||
string productCount, string prodorderId, string appInfo);
|
||||
|
||||
//获取商品列表
|
||||
[DllImport("__Internal")]
|
||||
public static extern void GetSKUList();
|
||||
|
||||
//打点
|
||||
[DllImport("__Internal")]
|
||||
public static extern void SetGaUserInfo(string userId);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
public static extern void SetGaCommonInfo(string SetGaCommonInfo);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
public static extern void GAReportParams(int type, string eventstr, string paramstr);
|
||||
|
||||
//ATT
|
||||
[DllImport("__Internal")]
|
||||
public static extern void RequestATT();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
public static extern int GetATT();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
public static extern void FBShareLink(string title, string content, string url);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
public static extern void MessengerShareLink(string title, string content, string url);
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
11
Packages/tysdk/Runtime/UnityBridgeFunc.cs.meta
Normal file
11
Packages/tysdk/Runtime/UnityBridgeFunc.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 16335dd05906d48bf81e297920aecf31
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
17
Packages/tysdk/Runtime/tysdk.asmdef
Normal file
17
Packages/tysdk/Runtime/tysdk.asmdef
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "tysdk",
|
||||
"rootNamespace": "tysdk",
|
||||
"references": [],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": true,
|
||||
"precompiledReferences": [
|
||||
"asap.core.dll",
|
||||
"Newtonsoft.Json.dll"
|
||||
],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
7
Packages/tysdk/Runtime/tysdk.asmdef.meta
Normal file
7
Packages/tysdk/Runtime/tysdk.asmdef.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b208fff54a2d840269b62e6585c0b390
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user