sdk 代码合并

This commit is contained in:
LYP
2024-08-06 16:22:00 +08:00
parent 4f80b73fd0
commit de5c781bd7
15 changed files with 1470 additions and 250 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,3 +1,4 @@
using System.Collections.Generic;
using tysdk; using tysdk;
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
@@ -5,37 +6,45 @@ using UnityEngine.UI;
public class SDKTest : MonoBehaviour public class SDKTest : MonoBehaviour
{ {
[SerializeField] [SerializeField]
private Button guestLoginBtn; private Button _loginGuestBtn;
[SerializeField] [SerializeField]
private Button googoleLoginBtn; private Button _loginGoogleBtn;
[SerializeField] [SerializeField]
private Button facebookLoginBtn; private Button _loginFbBtn;
[SerializeField] [SerializeField]
private Button LogOutBtn; private Button _logOutBtn;
[SerializeField] [SerializeField]
private Text log; private Button _payTestBtn;
[SerializeField]
private Button _payListBtn;
[SerializeField]
private Button _gaTestBtn;
[SerializeField]
private Button _gaAppMaxBtn;
[SerializeField]
private Text _messageTxt;
void Start() void Start()
{ {
guestLoginBtn.onClick.AddListener(() => OnLogin(EAccoutType.hwGuest)); _loginGuestBtn.onClick.AddListener(() => OnLogin(EAccoutType.hwGuest));
googoleLoginBtn.onClick.AddListener(() => OnLogin(EAccoutType.hwGoogle)); _loginGoogleBtn.onClick.AddListener(() => OnLogin(EAccoutType.hwGoogle));
facebookLoginBtn.onClick.AddListener(() => OnLogin(EAccoutType.hwFacebook)); _loginFbBtn.onClick.AddListener(() => OnLogin(EAccoutType.hwFacebook));
LogOutBtn.onClick.AddListener(OnLogout); _logOutBtn.onClick.AddListener(OnLogout);
_payTestBtn.onClick.AddListener(OnPayTestBtn);
_payListBtn.onClick.AddListener(OnPayListBtn);
_gaTestBtn.onClick.AddListener(OnGaBtn);
_gaAppMaxBtn.onClick.AddListener(OnAppMaxBtn);
} }
private async void OnLogin(EAccoutType accoutType) private async void OnLogin(EAccoutType accoutType)
{ {
log.text = string.Empty; _messageTxt.text = string.Empty;
var info = await TYSdkFacade.Instance.Login(accoutType); var info = await TYSdkFacade.Instance.Login(accoutType);
log.text = $"Login: {info.isSuccess}"; _messageTxt.text = $"Login: {info.isSuccess}";
if(info.isSuccess) if(info.isSuccess)
{ {
log.text += $"\n{info.msg}"; _messageTxt.text += $"\n{info.msg}";
log.text += $"\n{TYSdkFacade.Instance.TYAccountInfo.token}"; _messageTxt.text += $"\n{TYSdkFacade.Instance.TYAccountInfo.token}";
} }
} }
@@ -43,4 +52,38 @@ public class SDKTest : MonoBehaviour
{ {
TYSdkFacade.Instance.Logout(); TYSdkFacade.Instance.Logout();
} }
public async void OnPayTestBtn()
{
string prodId = "comarkgameft1chooseone0199";
string pType = "googleiab.global.app";
string prodPrice = "2,616";
string prodName = "test:₩2,616";
int count = 1;
Debug.LogError($"[AggSdk::Pay] prodId : {prodId} prodPrice : {prodPrice} prodName : {prodName} ");
PaymentInfo payResult = await TYSdkFacade.Instance.Pay(prodId, prodPrice, prodName, count, pType);
}
public async void OnPayListBtn()
{
Debug.LogError("PayList ask");
var result = await TYSdkFacade.Instance.ThirdExtend();
}
public void OnGaBtn()
{
Debug.LogError("Ga ask");
using ( var e = GAEvent.TackEvent("idcheckdone") )
{
e.AddContent("test ga", true);
}
}
public void OnAppMaxBtn()
{
// TYSdkFacade.Instance.PlayAd();
}
} }

View File

@@ -7,7 +7,7 @@ using UnityEngine;
namespace tysdk namespace tysdk
{ {
public class TYSdkFacade : MonoBehaviour public partial class TYSdkFacade : MonoBehaviour
{ {
public class AccountInfo public class AccountInfo
{ {
@@ -30,12 +30,19 @@ namespace tysdk
if (_instance == null) if (_instance == null)
{ {
_instance = new GameObject("TYSdkFacade").AddComponent<TYSdkFacade>(); _instance = new GameObject("TYSdkFacade").AddComponent<TYSdkFacade>();
Init();
DontDestroyOnLoad(_instance.gameObject); DontDestroyOnLoad(_instance.gameObject);
} }
return _instance; return _instance;
} }
} }
public static void Init()
{
UnityBridgeFunc.InitSDK();
}
/*================================================ /*================================================
_ _ _ _
@@ -139,190 +146,5 @@ namespace tysdk
UnityBridgeFunc.UnitySetAdBoxUserInfo(strUserId); UnityBridgeFunc.UnitySetAdBoxUserInfo(strUserId);
UnityBridgeFunc.UnityInitADSConfig(); UnityBridgeFunc.UnityInitADSConfig();
} }
/*================================================
_____ _ _____ _
| ____|_ _____ _ __ | |_ |_ _| __ __ _ ___| | __
| _| \ \ / / _ \ '_ \| __| | || '__/ _` |/ __| |/ /
| |___ \ V / __/ | | | |_ | || | | (_| | (__| <
|_____| \_/ \___|_| |_|\__| |_||_| \__,_|\___|_|\_\
=================================================*/
public void EventTrack(int type, string name, string content)
{
#if UNITY_IOS || UNITY_ANDROID
UnityBridgeFunc.GAReportParams(type, name, content);
#endif
}
/*================================================
____ _
| _ \ __ _ _ _ _ __ ___ ___ _ __ | |_
| |_) / _` | | | | '_ ` _ \ / _ \ '_ \| __|
| __/ (_| | |_| | | | | | | __/ | | | |_
|_| \__,_|\__, |_| |_| |_|\___|_| |_|\__|
|___/
=================================================*/
//TODO
public async Task<PaymentInfo> Pay(string prodId, string prodPrice, string prodName, int count, string orderId, string extraInfo)
{
if (!IsLoggedIn) return new PaymentInfo() { code = "-1", msg = "未登录" };
#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 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;
#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:");
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");
}
}
/*================================================
_ _____ _____
/ \|_ _|_ _|
/ _ \ | | | |
/ ___ \| | | |
/_/ \_\_| |_|
=================================================*/
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");
}
}
/*================================================
_ ____
/ \ | _ \
/ _ \ | | | |
/ ___ \| |_| |
/_/ \_\____/
=================================================*/
public void InitAdCallback(string jstr)
{
try{
var jobj = JObject.Parse(jstr);
if(jobj["code"].ToString() == "0")
UnityEngine.Debug.Log($"[TYSdkFacade] InitAdCallback Success");
else
UnityEngine.Debug.LogError($"[TYSdkFacade] InitAdCallback Failed ");
}
catch(Exception e)
{
UnityEngine.Debug.LogError($"[TYSdkFacade] InitAdCallback error: {e.Message}");
}
}
public void LoadAdCallback(string jstr)
{
try
{
var adLoadinfo = Newtonsoft.Json.JsonConvert.DeserializeObject<ADLoadInfo>(jstr);
GContext.Publish(adLoadinfo);
}
catch (Exception e)
{
UnityEngine.Debug.LogError($"[TYSdkFacade] LoadAdCallback error: {e.Message}");
}
}
public void ShowAdCallback(string jstr)
{
try
{
var adShowInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<ShowADInfo>(jstr);
GContext.Publish(adShowInfo);
}
catch (Exception e)
{
UnityEngine.Debug.LogError($"[TYSdkFacade] ShowAdCallback error: {e.Message}");
}
}
} }
} }

View File

@@ -0,0 +1,61 @@
using System;
using asap.core;
using Newtonsoft.Json.Linq;
using UnityEngine;
namespace tysdk
{
public partial class TYSdkFacade : MonoBehaviour
{
/*================================================
_ ____
/ \ | _ \
/ _ \ | | | |
/ ___ \| |_| |
/_/ \_\____/
=================================================*/
public void InitAdCallback(string jstr)
{
try{
var jobj = JObject.Parse(jstr);
if(jobj["code"].ToString() == "0")
UnityEngine.Debug.Log($"[TYSdkFacade] InitAdCallback Success");
else
UnityEngine.Debug.LogError($"[TYSdkFacade] InitAdCallback Failed ");
}
catch(Exception e)
{
UnityEngine.Debug.LogError($"[TYSdkFacade] InitAdCallback error: {e.Message}");
}
}
public void LoadAdCallback(string jstr)
{
try
{
var adLoadinfo = Newtonsoft.Json.JsonConvert.DeserializeObject<ADLoadInfo>(jstr);
GContext.Publish(adLoadinfo);
}
catch (Exception e)
{
UnityEngine.Debug.LogError($"[TYSdkFacade] LoadAdCallback error: {e.Message}");
}
}
public void ShowAdCallback(string jstr)
{
try
{
var adShowInfo = Newtonsoft.Json.JsonConvert.DeserializeObject<ShowADInfo>(jstr);
GContext.Publish(adShowInfo);
}
catch (Exception e)
{
UnityEngine.Debug.LogError($"[TYSdkFacade] ShowAdCallback error: {e.Message}");
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 179ddafea9354cadbfabca342e552139
timeCreated: 1722855804

View 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");
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 8f92075f5f98490ca94ae4984ac0aa21
timeCreated: 1722855901

View File

@@ -0,0 +1,131 @@
using System;
using Newtonsoft.Json.Linq;
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;
public static string ABTestValue = "0";
private JObject content = new JObject();
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 void Dispose()
{
content["ABTestValue"] = ABTestValue;
TYSdkFacade.Instance.EventTrack((int)eventType, eventName, content.ToString());
}
/*
*GA_TRACK默认类型
*GA_CION金流相关事件
*GA_PAY支付相关事件
*GA_GAME游戏行为
*GA_LOGIN登录注册相关事件
*GA_PUSH推送相关事件
*GA_ADBOXadbox相关事件
*GA_PREFORMANCE性能上报相关事件
*GA_SDKSDK相关事件
*GA_ABTestabtest相关事件
*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);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 18459dcf8d5a40dc80ffae5333a6b0c9
timeCreated: 1722855439

View File

@@ -0,0 +1,36 @@
// using System;
// using AppLovinMax;
// using UnityEngine;
//
// namespace tysdk
// {
// public partial class TYSdkFacade : MonoBehaviour
// {
// #if UNITY_IOS
// public const string AppOpenAdUnitId = "4cea568d96f9c9d3";
// #else
// public const string AppOpenAdUnitId = "4cea568d96f9c9d3";
// #endif
// public string[] TestIds = new string[] { "4cea568d96f9c9d3","cd71530d3089c3ec","1a2e78ad8aa5690f"};
// public int adIndex = 0;
// public async void PlayAd()
// {
// await AppMaxManager.Instance().MaxInit();
// if (adIndex >= TestIds.Length - 1)
// {
// adIndex = 0;
// }
//
// adIndex++;
// Debug.LogError("广告id::::::::" + TestIds[adIndex]);
// if (MaxSdk.IsRewardedAdReady(TestIds[adIndex]))
// {
// MaxSdk.ShowRewardedAd(TestIds[adIndex]);
// }
// else
// {
// MaxSdk.LoadRewardedAd(TestIds[adIndex]);
// }
// }
// }
// }

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d16ab34307a144e0bf15b770e3824309
timeCreated: 1722854562

View File

@@ -0,0 +1,133 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
using UnityEngine;
namespace tysdk
{
public partial class TYSdkFacade : MonoBehaviour
{
/*================================================
____ _
| _ \ __ _ _ _ _ __ ___ ___ _ __ | |_
| |_) / _` | | | | '_ ` _ \ / _ \ '_ \| __|
| __/ (_| | |_| | | | | | | __/ | | | |_
|_| \__,_|\__, |_| |_| |_|\___|_| |_|\__|
|___/
=================================================*/
public async Task<PaymentInfo> Pay(string prodId, string prodPrice, string prodName, int count,string pType)
{
if (!IsLoggedIn) return new PaymentInfo() { code = "-1", msg = "未登录" };
var orderId = System.Guid.NewGuid().ToString();
var extraDic = new Dictionary<string,object>() {
{"paytime" , System.DateTime.UtcNow.Ticks},
{"sum" , float.Parse(prodPrice) * count},
};
string extraInfo = Newtonsoft.Json.JsonConvert.SerializeObject(extraDic);
//to base64
extraInfo = System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(extraInfo));
#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 taskSource = new TaskCompletionSource<PaymentInfo>();
callbacks.Add("PayResult", (ITYSdkCallback callback) =>
{
taskSource.SetResult((PaymentInfo)callback);
});
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.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;
#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<SKUDetail> ThirdExtend()
{
if (!IsLoggedIn) return new SKUDetail() { code = "-1", msg = "未登录" };
#if UNITY_EDITOR
await Task.Yield();
var result = new SKUDetail();
return result;
#elif UNITY_ANDROID
var taskSource = new TaskCompletionSource<SKUDetail>();
callbacks.Add("PayTypeResult", (ITYSdkCallback callback) =>
{
taskSource.SetResult((SKUDetail)callback);
});
UnityBridgeFunc.ThirdExtend();
var result = await taskSource.Task;
return result;
#endif
}
//商品列表的回调
public void PayTypeResult(string json)
{
Debug.Log("[thirdExtend] pay callback:");
var jresult = JObject.Parse(json);
var result = new SKUDetail();
result.code = jresult["code"].ToString();
result.msg = jresult["thirdExtend_errStr"].ToString();
if (callbacks.TryGetValue("PayTypeResult", out var action))
{
action.Invoke(result);
callbacks.Remove("PayTypeResult");
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 41b6dc16dbab43388317bf9ff032cdca
timeCreated: 1722855703

View File

@@ -1,6 +1,13 @@
namespace tysdk namespace tysdk
{ {
public enum EAccoutType
{
hwGoogle,
hwFacebook,
hwGuest,
none
}
public interface ITYSdkCallback { } public interface ITYSdkCallback { }
public class LoginInfo : ITYSdkCallback public class LoginInfo : ITYSdkCallback
@@ -29,6 +36,18 @@ namespace tysdk
} }
} }
public class SKUDetail: ITYSdkCallback
{
public string code;
public string msg;
public string name;
public string description;
public string price;
public string productId;
public string ourProductId;
public string currency_code;
}
public class ATTInfo : ITYSdkCallback public class ATTInfo : ITYSdkCallback
{ {
public bool isAccepted; public bool isAccepted;

View File

@@ -4,16 +4,12 @@ using UnityEngine;
namespace tysdk namespace tysdk
{ {
public enum EAccoutType
{
hwGoogle,
hwFacebook,
hwGuest,
}
public static class UnityBridgeFunc public static class UnityBridgeFunc
{ {
#if UNITY_EDITOR #if UNITY_EDITOR
//初始化sdk
public static void InitSDK(){}
//更新登录支付域名 //更新登录支付域名
public static void UnityResetServerUrl(string url){} public static void UnityResetServerUrl(string url){}
@@ -24,14 +20,21 @@ namespace tysdk
public static void UnityGetIdentityFun(string type){} public static void UnityGetIdentityFun(string type){}
public static void UnityLoginOut(){} public static void UnityLoginOut(){}
//支付new
public static void UnityKnowNew(string productId, string productPrice, string productName,
string productCount, string prodorderId, string appInfo, string pType) { }
//支付 //支付
public static void UnityKnow(string userId, string productId, string productPrice, string productName, public static void UnityKnow(string userId, string productId, string productPrice, string productName,
string productCount, string prodorderId, string appInfo){} string productCount, string prodorderId, string appInfo){}
//获取商品列表
public static void ThirdExtend() { }
//打点 //打点
public static void SetGaUserInfo(string userId){} public static void SetGaUserInfo(string userId){}
public static void SetGaCommonInfo(string SetGaCommonInfo){} public static void SetGaCommonInfo(string SetGaCommonInfo){}
public static void GAReportParams(int type, string eventstr, string paramstr){} public static void GAReportParams(int type, string eventstr, string paramstr){}
@@ -50,10 +53,22 @@ namespace tysdk
public static void UnityShowRVAD(){} public static void UnityShowRVAD(){}
#elif UNITY_ANDROID #elif UNITY_ANDROID
private static string SDK_CLASS = "com.unity3d.player.SDKManager"; 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) public static void UnityResetServerUrl(string url)
{ {
@@ -108,6 +123,17 @@ namespace tysdk
} }
} }
//支付new
public static void UnityKnowNew(string productId, string productPrice, string productName,
string productCount, string prodorderId, string appInfo,string pType)
{
Debug.LogError("[UnityKnowNew] pType:" + pType);
using(var sdkManager = new AndroidJavaClass(SDK_CLASS))
{
sdkManager.CallStatic("UnityKnowNew", productId, productPrice, productName,
productCount, prodorderId, appInfo,pType);
}
}
//支付 //支付
public static void UnityKnow(string userId, string productId, string productPrice, string productName, public static void UnityKnow(string userId, string productId, string productPrice, string productName,
string productCount, string prodorderId, string appInfo) string productCount, string prodorderId, string appInfo)
@@ -119,6 +145,15 @@ namespace tysdk
} }
} }
//获取商品列表
public static void ThirdExtend()
{
using(var sdkManager = new AndroidJavaClass(SDK_CLASS))
{
sdkManager.CallStatic("thirdExtend");
}
}
//打点 //打点
public static void SetGaUserInfo(string userId) public static void SetGaUserInfo(string userId)
{ {
@@ -205,6 +240,13 @@ namespace tysdk
public static extern void UnityKnow(string userId, string productId, string productPrice, string productName, public static extern void UnityKnow(string userId, string productId, string productPrice, string productName,
string productCount, string prodorderId, string appInfo); string productCount, string prodorderId, string appInfo);
//支付new
[DllImport("__Internal")]
public static extern void UnityKnowNew(string productId, string productPrice, string productName,
string productCount, string prodorderId, string appInfo, string pType);
//获取商品列表
[DllImport("__Internal")]
public static extern void ThirdExtend();
//打点 //打点
[DllImport("__Internal")] [DllImport("__Internal")]
public static extern void SetGaUserInfo(string userId); public static extern void SetGaUserInfo(string userId);