更新Touka SDK
This commit is contained in:
parent
280fdcce5f
commit
379b357f68
|
|
@ -8,6 +8,8 @@
|
|||
android:name="com.u8.sdk.U8Application"
|
||||
android:allowBackup="true"
|
||||
android:extractNativeLibs="true"
|
||||
android:hardwareAccelerated="true"
|
||||
android:largeHeap="true"
|
||||
android:networkSecurityConfig="@xml/network_security_config"
|
||||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
|
||||
android:usesCleartextTraffic="true"
|
||||
|
|
@ -19,8 +21,8 @@
|
|||
<activity
|
||||
android:name="com.u8.sdk.U8UnityContext"
|
||||
android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale|layoutDirection|density"
|
||||
android:hardwareAccelerated="false"
|
||||
android:launchMode="singleTask"
|
||||
android:launchMode="standard"
|
||||
android:exported="true"
|
||||
android:resizeableActivity="false"
|
||||
android:screenOrientation="fullSensor"
|
||||
android:theme="@style/UnityThemeSelector">
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 683ae343e269e401d9aa8d81710ea743
|
||||
guid: b2e24f251cb7842debe2bec6232b5b2d
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -4,11 +4,33 @@ using System.Collections.Generic;
|
|||
using UnityEngine;
|
||||
using UnityEngine.Purchasing;
|
||||
using Touka;
|
||||
using UnityEngine.Purchasing.Extension;
|
||||
using Unity.Services.Core;
|
||||
using Unity.Services.Core.Environments;
|
||||
|
||||
public class IAPTool : NormalSingleton<IAPTool>, IStoreListener
|
||||
namespace Touka
|
||||
{
|
||||
public class IAPTool : NormalSingleton<IAPTool>, IDetailedStoreListener
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取到在AppStore和Google Play 上配置的商品时回调
|
||||
/// 游戏可根据返回的商品列表进行商品UI的展示或隐藏
|
||||
/// </summary>
|
||||
public event Action<Product[]> OnGetProductsInfo;
|
||||
|
||||
/// <summary>
|
||||
/// 拉起支付窗口,开始支付流程时回调
|
||||
/// </summary>
|
||||
public event Action OnPurchaseBegin;
|
||||
public event Action<string, bool> OnPurchaseDone;
|
||||
|
||||
|
||||
|
||||
private static string mProductName = "";
|
||||
private static string mGameExtraParam = "";
|
||||
|
||||
/// <summary>
|
||||
/// 恢复购买回调
|
||||
/// </summary>
|
||||
public event Action<bool> OnRestoreDone;
|
||||
|
||||
public bool IsRestoring => mIsRestoring;
|
||||
|
|
@ -21,8 +43,33 @@ public class IAPTool : NormalSingleton<IAPTool>, IStoreListener
|
|||
private Dictionary<string, ProductType> mInitProductDic;
|
||||
private SubscriptionInfo mSubsInfo = null;
|
||||
|
||||
private const string Environment = "production";
|
||||
private bool mServiceInit = false;
|
||||
|
||||
private bool IsFetchingAdditionalProducts = false;
|
||||
|
||||
private Dictionary<string, ProductType> mAddProductsDic;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 初始化UnityServices
|
||||
/// </summary>
|
||||
public void PreInitialize()
|
||||
{
|
||||
TKGDebugger.LogDebug("PreInitialize() mServiceInit: " + mServiceInit);
|
||||
if (!mServiceInit)
|
||||
{
|
||||
InitializeUnityServices(OnSuccess, OnError);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化IAP
|
||||
/// </summary>
|
||||
public void Initialize()
|
||||
{
|
||||
TKGDebugger.LogDebug("IAP Initialize() m_StoreController:" + m_StoreController +
|
||||
" m_StoreExtensionProvider: " + m_StoreExtensionProvider);
|
||||
if (m_StoreController == null && m_StoreExtensionProvider == null)
|
||||
InitUnityPurchase();
|
||||
}
|
||||
|
|
@ -32,14 +79,57 @@ public class IAPTool : NormalSingleton<IAPTool>, IStoreListener
|
|||
return m_StoreController != null && m_StoreExtensionProvider != null;
|
||||
}
|
||||
|
||||
public void AddProducts(Dictionary<string, ProductType> pInitProductDic)
|
||||
/// <summary>
|
||||
/// IAP初始化后,可使用此接口,添加新增商品id
|
||||
/// </summary>
|
||||
/// <param name="pInitProductDic">商品IDs</param>
|
||||
/// <param name="onProductsResult">bool:添加新增商品id结果 string:附加信息</param>
|
||||
[Obsolete(
|
||||
"AddProducts(Dictionary<string, ProductType> products, Action<bool, string> onProductsResult = null) is deprecated, please use TKGSDKManager.Instance.BuyProductByID(string productId) instead.")]
|
||||
public void AddProducts(Dictionary<string, ProductType> products, Action<bool, string> onProductsResult = null)
|
||||
{
|
||||
mInitProductDic = pInitProductDic;
|
||||
mInitProductDic = products;
|
||||
|
||||
FetchAdditionalProducts(products, onProductsResult);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化UnityServices
|
||||
/// </summary>
|
||||
/// <param name="onSuccess"></param>
|
||||
/// <param name="onError"></param>
|
||||
private void InitializeUnityServices(Action onSuccess, Action<string> onError)
|
||||
{
|
||||
try
|
||||
{
|
||||
var options = new InitializationOptions().SetEnvironmentName(Environment);
|
||||
|
||||
UnityServices.InitializeAsync(options).ContinueWith(task => onSuccess());
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
onError(exception.Message);
|
||||
}
|
||||
}
|
||||
|
||||
void OnSuccess()
|
||||
{
|
||||
var text = "Congratulations!\nUnity Gaming Services has been successfully initialized.";
|
||||
TKGDebugger.LogDebug(text);
|
||||
mServiceInit = true;
|
||||
}
|
||||
|
||||
void OnError(string message)
|
||||
{
|
||||
var text = $"Unity Gaming Services failed to initialize with error: {message}.";
|
||||
TKGDebugger.LogError(text);
|
||||
}
|
||||
|
||||
|
||||
// 初始化IAP;
|
||||
private void InitUnityPurchase()
|
||||
{
|
||||
TKGDebugger.LogDebug("IAP InitUnityPurchase() IsInitialized: " + IsInitialized());
|
||||
if (IsInitialized()) return;
|
||||
|
||||
// 标准采购模块;
|
||||
|
|
@ -50,53 +140,185 @@ public class IAPTool : NormalSingleton<IAPTool>, IStoreListener
|
|||
|
||||
// 注意ProductType的类型,Consumable是可以无限购买(比如水晶),NonConsumable是只能购买一次(比如关卡),Subscription是每月订阅(比如VIP);
|
||||
// 这里初始化没有添加平台信息,因为平台信息有的时候还存在bug,如果必须添加,也可以添加,没有问题,确保平台信息添加正确就行了。
|
||||
|
||||
int productsNum = 0;
|
||||
foreach (string tID in IAPProducts.ProductDic.Keys)
|
||||
{
|
||||
productsNum++;
|
||||
if (!string.IsNullOrEmpty(tID))
|
||||
{
|
||||
TKGDebugger.LogDebug($"Add IAPProducts IAPProducts: {tID}");
|
||||
builder.AddProduct(tID, IAPProducts.ProductDic[tID]);
|
||||
}
|
||||
}
|
||||
|
||||
if (mInitProductDic != null && mInitProductDic.Count > 0)
|
||||
{
|
||||
foreach (string tID in mInitProductDic.Keys)
|
||||
{
|
||||
productsNum++;
|
||||
if (!string.IsNullOrEmpty(tID))
|
||||
{
|
||||
TKGDebugger.LogDebug($"Add InitProductDic APProducts: {tID}");
|
||||
builder.AddProduct(tID, mInitProductDic[tID]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mAddProductsDic != null && mAddProductsDic.Count > 0)
|
||||
{
|
||||
foreach (string tID in mAddProductsDic.Keys)
|
||||
{
|
||||
productsNum++;
|
||||
if (!string.IsNullOrEmpty(tID))
|
||||
{
|
||||
TKGDebugger.LogDebug($"Add AddProductsDic IAPProducts: {tID}");
|
||||
builder.AddProduct(tID, mAddProductsDic[tID]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (productsNum > 0)
|
||||
{
|
||||
//初始化;
|
||||
UnityPurchasing.Initialize(this, builder);
|
||||
}
|
||||
else
|
||||
{
|
||||
TKGDebugger.LogDebug(
|
||||
"UnityPurchasing will not initialize.Products is empty,please invoke TKGSDKManager.Instance.BuyProductByID(string productId) add product.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量获取其他产品
|
||||
/// </summary>
|
||||
private void FetchAdditionalProducts(Dictionary<string, ProductType> ProductDic,
|
||||
Action<bool, string> onProductsResult = null)
|
||||
{
|
||||
if (!IsInitialized())
|
||||
{
|
||||
mAddProductsDic = ProductDic;
|
||||
TKGDebugger.LogDebug("IAP not init.Now InitUnityPurchase");
|
||||
InitUnityPurchase();
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsFetchingAdditionalProducts)
|
||||
{
|
||||
TKGDebugger.LogDebug("Now fetching additional products,don't call repeatedly");
|
||||
if (onProductsResult != null)
|
||||
{
|
||||
onProductsResult(false, "Now fetching additional products,don't call repeatedly");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
IsFetchingAdditionalProducts = true;
|
||||
if (ProductDic != null)
|
||||
{
|
||||
var additional = new HashSet<ProductDefinition>();
|
||||
foreach (string tID in ProductDic.Keys)
|
||||
{
|
||||
additional.Add(new ProductDefinition(tID, ProductDic[tID]));
|
||||
}
|
||||
|
||||
Action onSuccess = () =>
|
||||
{
|
||||
IsFetchingAdditionalProducts = false;
|
||||
|
||||
TKGDebugger.LogDebug("Fetched successfully!");
|
||||
if (OnGetProductsInfo != null)
|
||||
{
|
||||
OnGetProductsInfo(m_StoreController.products.all);
|
||||
}
|
||||
|
||||
foreach (var product in m_StoreController.products.all)
|
||||
{
|
||||
TKGDebugger.LogDebug(product.metadata.localizedTitle
|
||||
+ "|" + product.metadata.localizedPriceString
|
||||
+ "|" + product.metadata.localizedDescription
|
||||
+ "|" + product.metadata.isoCurrencyCode);
|
||||
}
|
||||
|
||||
if (onProductsResult != null)
|
||||
{
|
||||
onProductsResult(true, "Fetched successfully!");
|
||||
}
|
||||
};
|
||||
|
||||
Action<InitializationFailureReason, string> onFailure = (InitializationFailureReason i, string msg) =>
|
||||
{
|
||||
IsFetchingAdditionalProducts = false;
|
||||
if (onProductsResult != null)
|
||||
{
|
||||
onProductsResult(true, "Fetching failed for the specified reason: " + i + " msg: " + msg);
|
||||
}
|
||||
|
||||
Debug.Log("Fetching failed for the specified reason: " + i + " msg: " + msg);
|
||||
};
|
||||
|
||||
m_StoreController.FetchAdditionalProducts(additional, onSuccess, onFailure);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region Public Func
|
||||
// 根据ID给购买商品;
|
||||
public void BuyProductByID(string productId)
|
||||
|
||||
/// <summary>
|
||||
/// 根据商品ID 购买商品;
|
||||
/// </summary>
|
||||
/// <param name="productId">商品ID</param>
|
||||
[Obsolete(
|
||||
"BuyProductByID(string productId) is deprecated, please use TKGSDKManager.Instance.BuyProductByID(string productId) instead.")]
|
||||
public void BuyProductByID(string productId, string productName, string gameExtraParam)
|
||||
{
|
||||
mProductName = productName;
|
||||
mGameExtraParam = gameExtraParam;
|
||||
|
||||
TKGNativeInterface.Instance.LogIAPBtnClick(productName, productId);
|
||||
|
||||
// 设置监听购买二次验证的回调
|
||||
TKGSDKCallback.SetSecondPurchaseCallback(TKGSDKManager.Instance.OnPurchaseDone);
|
||||
|
||||
if (IsInitialized())
|
||||
{
|
||||
if (m_PurchaseInProgress == true) return;
|
||||
if (m_PurchaseInProgress)
|
||||
{
|
||||
TKGDebugger.LogDebug("The payment is in progress, please do not initiate the payment repeatedly.");
|
||||
return;
|
||||
}
|
||||
|
||||
Product product = m_StoreController.products.WithID(productId);
|
||||
if (product != null && product.availableToPurchase)
|
||||
{
|
||||
OnPurchaseBegin?.Invoke();
|
||||
m_PurchaseInProgress = true;
|
||||
TKGDebugger.LogDebug(string.Format("Purchasing product asychronously: '{0}'", product.definition.id));
|
||||
TKGDebugger.LogDebug(
|
||||
string.Format("Purchasing product asychronously: '{0}'", product.definition.id));
|
||||
m_StoreController.InitiatePurchase(product);
|
||||
}
|
||||
else
|
||||
{
|
||||
TKGDebugger.LogDebug("BuyProductID: FAIL. Not purchasing product, either is not found or is not available for purchase");
|
||||
TKGDebugger.LogDebug(
|
||||
"BuyProductID: FAIL. Not purchasing product, either is not found or is not available for purchase");
|
||||
TKGNativeInterface.Instance.ClientIAPFailed(mProductName, productId, "", "", "", "", mGameExtraParam, IAPClientFailReasonType.NotInit);
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TKGDebugger.LogDebug("BuyProductID FAIL. Not initialized.");
|
||||
TKGDebugger.LogDebug("BuyProductID FAIL. IAP Not initialized or Not add product.");
|
||||
//OnPurchaseDone?.Invoke(productId, false, "", "");
|
||||
|
||||
TKGDebugger.LogDebug("OnPurchaseFailed -> productId : " + productId + " , transactionID : " + "" + " , localizedPrice : " + "" + " , isoCurrencyCode : " + "");
|
||||
TKGNativeInterface.Instance.ClientIAPFailed(mProductName, productId, "", "", "", "", mGameExtraParam, IAPClientFailReasonType.NotInit);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// 确认购买产品成功;
|
||||
public void DoConfirmPendingPurchaseByID(string productId)
|
||||
private void DoConfirmPendingPurchaseByID(string productId)
|
||||
{
|
||||
Product product = m_StoreController.products.WithID(productId);
|
||||
if (product != null && product.availableToPurchase)
|
||||
|
|
@ -109,7 +331,10 @@ public class IAPTool : NormalSingleton<IAPTool>, IStoreListener
|
|||
}
|
||||
}
|
||||
|
||||
// 恢复购买;
|
||||
/// <summary>
|
||||
/// 恢复购买
|
||||
/// </summary>
|
||||
[Obsolete("RestorePurchases() is deprecated, please use TKGSDKManager.Instance.RestorePurchases() instead.")]
|
||||
public void RestorePurchases()
|
||||
{
|
||||
if (!IsInitialized())
|
||||
|
|
@ -118,28 +343,34 @@ public class IAPTool : NormalSingleton<IAPTool>, IStoreListener
|
|||
TKGDebugger.LogDebug("RestorePurchases FAIL. Not initialized.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Application.platform == RuntimePlatform.IPhonePlayer ||
|
||||
Application.platform == RuntimePlatform.OSXPlayer)
|
||||
{
|
||||
TKGDebugger.LogDebug("RestorePurchases started ...");
|
||||
mIsRestoring = true;
|
||||
var apple = m_StoreExtensionProvider.GetExtension<IAppleExtensions>();
|
||||
apple.RestoreTransactions((result) => {
|
||||
apple.RestoreTransactions((result, msg) =>
|
||||
{
|
||||
mIsRestoring = false;
|
||||
OnRestoreDone?.Invoke(result);
|
||||
// 返回一个bool值,如果成功,则会多次调用支付回调,然后根据支付回调中的参数得到商品id,最后做处理(ProcessPurchase);
|
||||
TKGDebugger.LogDebug("RestorePurchases continuing: " + result + ". If no further messages, no purchases available to restore.");
|
||||
TKGDebugger.LogDebug("RestorePurchases continuing: " + result + "msg:" + msg
|
||||
+ " If no further messages, no purchases available to restore.");
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
TKGDebugger.LogDebug("RestorePurchases FAIL. Not supported on this platform. Current = " + Application.platform);
|
||||
TKGDebugger.LogDebug("RestorePurchases FAIL. Not supported on this platform. Current = "
|
||||
+ Application.platform);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IStoreListener Callback
|
||||
// IAP初始化成功回掉函数;
|
||||
|
||||
// IAP初始化成功回调函数;
|
||||
public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
|
||||
{
|
||||
TKGDebugger.LogDebug("IAP initialize Succeed!");
|
||||
|
|
@ -148,18 +379,25 @@ public class IAPTool : NormalSingleton<IAPTool>, IStoreListener
|
|||
m_StoreExtensionProvider = extensions;
|
||||
|
||||
// 这里可以获取您在AppStore和Google Play 上配置的商品;
|
||||
ProductCollection products = m_StoreController.products;
|
||||
Product[] all = products.all;
|
||||
for (int i = 0; i < all.Length; i++)
|
||||
if (OnGetProductsInfo != null)
|
||||
{
|
||||
TKGDebugger.LogDebug(all[i].metadata.localizedTitle + "|" + all[i].metadata.localizedPriceString + "|" + all[i].metadata.localizedDescription + "|" + all[i].metadata.isoCurrencyCode);
|
||||
OnGetProductsInfo(m_StoreController.products.all);
|
||||
}
|
||||
|
||||
|
||||
foreach (var product in m_StoreController.products.all)
|
||||
{
|
||||
TKGDebugger.LogDebug(product.metadata.localizedTitle
|
||||
+ "|" + product.metadata.localizedPriceString
|
||||
+ "|" + product.metadata.localizedDescription
|
||||
+ "|" + product.metadata.isoCurrencyCode);
|
||||
}
|
||||
|
||||
#if UNITY_IOS
|
||||
m_StoreExtensionProvider.GetExtension<IAppleExtensions>().RegisterPurchaseDeferredListener(OnDeferred);
|
||||
#endif
|
||||
|
||||
/*
|
||||
/*
|
||||
Dictionary<string, string> introductory_info_dict = null;
|
||||
|
||||
#if UNITY_IOS
|
||||
|
|
@ -224,12 +462,32 @@ public class IAPTool : NormalSingleton<IAPTool>, IStoreListener
|
|||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
*/
|
||||
}
|
||||
|
||||
public void OnPurchaseFailed(Product product, PurchaseFailureDescription failureDescription)
|
||||
{
|
||||
TKGDebugger.LogError(product.transactionID + "," + failureDescription.productId + "," +
|
||||
failureDescription.message);
|
||||
m_PurchaseInProgress = false;
|
||||
//OnPurchaseDone?.Invoke(product.definition.id, false, "", "");
|
||||
|
||||
TKGDebugger.LogDebug("productId : " + failureDescription.productId + " , transactionID : " + product.transactionID + " , localizedPrice : " + product.metadata.localizedPriceString + " , isoCurrencyCode : " + product.metadata.isoCurrencyCode);
|
||||
TKGNativeInterface.Instance.ClientIAPFailed(mProductName, failureDescription.productId, product.transactionID, "", product.metadata.isoCurrencyCode,product.metadata.localizedPrice.ToString(), mGameExtraParam, IAPClientFailReasonType.PurchaseFailed);
|
||||
}
|
||||
|
||||
public void OnInitializeFailed(InitializationFailureReason error)
|
||||
{
|
||||
OnInitializeFailed(error, "");
|
||||
}
|
||||
|
||||
// IAP初始化失败回掉函数(没有网络的情况下并不会调起,而是一直等到有网络连接再尝试初始化);
|
||||
public void OnInitializeFailed(InitializationFailureReason error)
|
||||
#pragma warning disable CS8632 // 只能在 "#nullable" 注释上下文内的代码中使用可为 null 的引用类型的注释。
|
||||
public void OnInitializeFailed(InitializationFailureReason error, string? message)
|
||||
#pragma warning restore CS8632 // 只能在 "#nullable" 注释上下文内的代码中使用可为 null 的引用类型的注释。
|
||||
{
|
||||
TKGDebugger.LogDebug("IAP OnInitializeFailed error:" + error.ToString());
|
||||
TKGDebugger.LogDebug("IAP OnInitializeFailed message:" + message);
|
||||
switch (error)
|
||||
{
|
||||
case InitializationFailureReason.AppNotKnown:
|
||||
|
|
@ -239,7 +497,8 @@ public class IAPTool : NormalSingleton<IAPTool>, IStoreListener
|
|||
TKGDebugger.LogDebug("Billing disabled! Ask the user if billing is disabled in device settings.");
|
||||
break;
|
||||
case InitializationFailureReason.NoProductsAvailable:
|
||||
TKGDebugger.LogDebug("No products available for purchase! Developer configuration error; check product metadata!");
|
||||
TKGDebugger.LogDebug(
|
||||
"No products available for purchase! Developer configuration error; check product metadata!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -252,31 +511,46 @@ public class IAPTool : NormalSingleton<IAPTool>, IStoreListener
|
|||
TKGDebugger.LogDebug("The product receipt does not contain enough information");
|
||||
return false;
|
||||
}
|
||||
var store = (string)receipt_wrapper ["Store"];
|
||||
var payload = (string)receipt_wrapper ["Payload"];
|
||||
|
||||
if (payload != null )
|
||||
var store = (string)receipt_wrapper["Store"];
|
||||
var payload = (string)receipt_wrapper["Payload"];
|
||||
|
||||
if (payload != null)
|
||||
{
|
||||
switch (store)
|
||||
{
|
||||
case GooglePlay.Name:
|
||||
{
|
||||
var payload_wrapper = (Dictionary<string, object>)MiniJson.JsonDecode(payload);
|
||||
if (!payload_wrapper.ContainsKey("json")) {
|
||||
TKGDebugger.LogDebug("The product receipt does not contain enough information, the 'json' field is missing");
|
||||
if (!payload_wrapper.ContainsKey("json"))
|
||||
{
|
||||
TKGDebugger.LogDebug(
|
||||
"The product receipt does not contain enough information, the 'json' field is missing");
|
||||
return false;
|
||||
}
|
||||
var original_json_payload_wrapper = (Dictionary<string, object>)MiniJson.JsonDecode((string)payload_wrapper["json"]);
|
||||
if (original_json_payload_wrapper == null || !original_json_payload_wrapper.ContainsKey("developerPayload")) {
|
||||
TKGDebugger.LogDebug("The product receipt does not contain enough information, the 'developerPayload' field is missing");
|
||||
|
||||
var original_json_payload_wrapper =
|
||||
(Dictionary<string, object>)MiniJson.JsonDecode((string)payload_wrapper["json"]);
|
||||
if (original_json_payload_wrapper == null ||
|
||||
!original_json_payload_wrapper.ContainsKey("developerPayload"))
|
||||
{
|
||||
TKGDebugger.LogDebug(
|
||||
"The product receipt does not contain enough information, the 'developerPayload' field is missing");
|
||||
return false;
|
||||
}
|
||||
|
||||
var developerPayloadJSON = (string)original_json_payload_wrapper["developerPayload"];
|
||||
var developerPayload_wrapper = (Dictionary<string, object>)MiniJson.JsonDecode(developerPayloadJSON);
|
||||
if (developerPayload_wrapper == null || !developerPayload_wrapper.ContainsKey("is_free_trial") || !developerPayload_wrapper.ContainsKey("has_introductory_price_trial")) {
|
||||
TKGDebugger.LogDebug("The product receipt does not contain enough information, the product is not purchased using 1.19 or later");
|
||||
var developerPayload_wrapper =
|
||||
(Dictionary<string, object>)MiniJson.JsonDecode(developerPayloadJSON);
|
||||
if (developerPayload_wrapper == null ||
|
||||
!developerPayload_wrapper.ContainsKey("is_free_trial") ||
|
||||
!developerPayload_wrapper.ContainsKey("has_introductory_price_trial"))
|
||||
{
|
||||
TKGDebugger.LogDebug(
|
||||
"The product receipt does not contain enough information, the product is not purchased using 1.19 or later");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
case AppleAppStore.Name:
|
||||
|
|
@ -291,10 +565,19 @@ public class IAPTool : NormalSingleton<IAPTool>, IStoreListener
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// 支付成功处理函数;
|
||||
//
|
||||
/// <summary>
|
||||
/// 支付成功处理函数;
|
||||
/// 在支持交易恢复功能的平台上(例如 Google Play 和通用 Windows 应用程序),
|
||||
/// Unity IAP 会在重新安装后的第一次初始化期间自动恢复用户拥有的任何商品;
|
||||
/// 系统将为每项拥有的商品调用 IStoreListener 的 ProcessPurchase 方法。
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
/// <returns></returns>
|
||||
public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs e)
|
||||
{
|
||||
m_PurchaseInProgress = false;
|
||||
|
|
@ -304,25 +587,90 @@ public class IAPTool : NormalSingleton<IAPTool>, IStoreListener
|
|||
// 消息结构 : Receipt: {"Store":"fake","TransactionID":"9c5c16a5-1ae4-468f-806d-bc709440448a","Payload":"{ \"this\" : \"is a fake receipt\" }"};
|
||||
TKGDebugger.LogDebug("Receipt: " + e.purchasedProduct.receipt);
|
||||
|
||||
OnPurchaseDone?.Invoke(e.purchasedProduct.definition.id, true);
|
||||
TKGSDKManager.Instance.SetSegment(SegmentType.Purchase);
|
||||
|
||||
//获取并解析你需要上传的数据。解析成string类型
|
||||
var wrapper = (Dictionary<string, object>)MiniJson.JsonDecode(e.purchasedProduct.receipt);
|
||||
|
||||
// Corresponds to http://docs.unity3d.com/Manual/UnityIAPPurchaseReceipts.html
|
||||
// 正在使用的商店的名称,例如 GooglePlay 或 AppleAppStore
|
||||
var store = (string)wrapper["Store"];
|
||||
TKGDebugger.LogDebug("Purchase OK: store" + store);
|
||||
//下面的payload 验证商品信息的数据。即我们需要上传的部分。
|
||||
// For Apple this will be the base64 encoded ASN.1 receipt
|
||||
// 对于苹果来说,这将是base64编码的ASN.1收据
|
||||
var payload = (string)wrapper["Payload"];
|
||||
TKGDebugger.LogDebug("Purchase OK: payload" + payload);
|
||||
|
||||
|
||||
string token;
|
||||
string orderId;
|
||||
if (Application.platform == RuntimePlatform.Android)
|
||||
{
|
||||
// For GooglePlay payload contains more JSON
|
||||
// 对于GooglePlay有效负载包含更多JSON
|
||||
var gpDetails = (Dictionary<string, object>)MiniJson.JsonDecode(payload);
|
||||
var gpJson = (string)gpDetails["json"];
|
||||
var tokenJson = (Dictionary<string, object>)MiniJson.JsonDecode(gpJson);
|
||||
token = (string)tokenJson["purchaseToken"];
|
||||
orderId = (string)tokenJson["orderId"];
|
||||
|
||||
TKGDebugger.LogDebug("ClientIAPSuccess productId : " + e.purchasedProduct.definition.id + " , transactionID : " + orderId + " , token : " + token + " , localizedPrice : " + e.purchasedProduct.metadata.localizedPriceString + " , isoCurrencyCode : " + e.purchasedProduct.metadata.isoCurrencyCode);
|
||||
TKGNativeInterface.Instance.ClientIAPSuccess(mProductName, e.purchasedProduct.definition.id, orderId, token, e.purchasedProduct.metadata.isoCurrencyCode, e.purchasedProduct.metadata.localizedPrice.ToString(), mGameExtraParam);
|
||||
|
||||
//if (orderId.StartsWith("GPA."))
|
||||
//{
|
||||
// TKGSDKManager.Instance.LogPurchasePrice(e.purchasedProduct.metadata.localizedPriceString,
|
||||
// e.purchasedProduct.metadata.isoCurrencyCode); // todo delete android upload event
|
||||
// OnPurchaseDone?.Invoke(e.purchasedProduct.definition.id, true, orderId, token);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// //OnPurchaseDone?.Invoke(e.purchasedProduct.definition.id, false, "", "");
|
||||
// TKGDebugger.LogDebug("productId : " + e.purchasedProduct.definition.id + " , transactionID : " + orderId + " , localizedPrice : " + e.purchasedProduct.metadata.localizedPriceString + " , isoCurrencyCode : " + e.purchasedProduct.metadata.isoCurrencyCode);
|
||||
// TKGNativeInterface.Instance.ClientIAPFailed("", e.purchasedProduct.definition.id, orderId, token, e.purchasedProduct.metadata.localizedPriceString, e.purchasedProduct.metadata.isoCurrencyCode);
|
||||
//}
|
||||
}
|
||||
else
|
||||
{
|
||||
//TKGSDKManager.Instance.LogPurchasePrice(e.purchasedProduct.metadata.localizedPriceString,
|
||||
// e.purchasedProduct.metadata.isoCurrencyCode); // todo delete iOS upload event
|
||||
//苹果验单直接传入 payload
|
||||
token = "";
|
||||
orderId = (string)wrapper["TransactionID"];
|
||||
//OnPurchaseDone?.Invoke(e.purchasedProduct.definition.id, true, orderId, token);
|
||||
|
||||
|
||||
TKGDebugger.LogDebug("ClientIAPSuccess productId : " + e.purchasedProduct.definition.id + " , transactionID : " + orderId + " , token : " + token + " , localizedPrice : " + e.purchasedProduct.metadata.localizedPriceString + " , isoCurrencyCode : " + e.purchasedProduct.metadata.isoCurrencyCode);
|
||||
TKGNativeInterface.Instance.ClientIAPSuccess(mProductName, e.purchasedProduct.definition.id, orderId, token, e.purchasedProduct.metadata.isoCurrencyCode, e.purchasedProduct.metadata.localizedPrice.ToString(),mGameExtraParam);
|
||||
|
||||
}
|
||||
|
||||
// 我们自己后台完毕的话,通过代码设置成功(如果是不需要后台设置直接设置完毕,不要设置Pending);
|
||||
return PurchaseProcessingResult.Complete;
|
||||
}
|
||||
|
||||
// 支付失败回掉函数;
|
||||
public void OnPurchaseFailed(Product item, PurchaseFailureReason r)
|
||||
public void OnPurchaseFailed(Product product, PurchaseFailureReason failureDescription)
|
||||
{
|
||||
TKGDebugger.LogDebug("Purchase OK: " + item.definition.id);
|
||||
TKGDebugger.LogDebug("Purchase OK: " + product.definition.id);
|
||||
m_PurchaseInProgress = false;
|
||||
OnPurchaseDone?.Invoke(item.definition.id, false);
|
||||
//OnPurchaseDone?.Invoke(item.definition.id, false, "", "");
|
||||
|
||||
TKGDebugger.LogDebug("OnPurchaseFailed -> productId : " + product.definition.id + " , transactionID : " + product.transactionID + " , localizedPrice : " + product.metadata.localizedPriceString + " , isoCurrencyCode : " + product.metadata.isoCurrencyCode);
|
||||
TKGNativeInterface.Instance.ClientIAPFailed(mProductName, product.definition.id, product.transactionID, "", product.metadata.isoCurrencyCode,product.metadata.localizedPrice.ToString(),mGameExtraParam, IAPClientFailReasonType.PurchaseFailed);
|
||||
|
||||
}
|
||||
|
||||
// 购买延迟提示(这个看自己项目情况是否处理);
|
||||
public void OnDeferred(Product item)
|
||||
// 在 Apple 平台上,我们需要处理由 Apple 的"购买前先询问"功能导致的延期购买。
|
||||
// 在非 Apple 平台上,这将不起作用;永远不会调用 OnDeferred。
|
||||
public void OnDeferred(Product product)
|
||||
{
|
||||
TKGDebugger.LogDebug("Purchase deferred: " + item.definition.id);
|
||||
OnPurchaseDone?.Invoke(item.definition.id, false);
|
||||
TKGDebugger.LogDebug("Purchase deferred: " + product.definition.id + " , maybe slow internet.");
|
||||
//OnPurchaseDone?.Invoke(item.definition.id, false, "", "");
|
||||
|
||||
TKGNativeInterface.Instance.ClientIAPFailed(mProductName, product.definition.id, product.transactionID, "", product.metadata.isoCurrencyCode, product.metadata.localizedPrice.ToString(), mGameExtraParam, IAPClientFailReasonType.Deferred);
|
||||
|
||||
}
|
||||
|
||||
// 恢复购买功能执行回掉函数;
|
||||
|
|
@ -330,9 +678,11 @@ public class IAPTool : NormalSingleton<IAPTool>, IStoreListener
|
|||
{
|
||||
TKGDebugger.LogDebug("Transactions restored : " + success);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region custom functions
|
||||
|
||||
public string GetPriceByID(string pID)
|
||||
{
|
||||
if (m_StoreController == null && m_StoreExtensionProvider == null)
|
||||
|
|
@ -341,7 +691,6 @@ public class IAPTool : NormalSingleton<IAPTool>, IStoreListener
|
|||
Product[] tProducts = m_StoreController.products.all;
|
||||
for (int i = 0; i < tProducts.Length; i++)
|
||||
{
|
||||
TKGDebugger.LogDebug(tProducts[i].metadata.localizedTitle + "|" + tProducts[i].metadata.localizedPriceString + "|" + tProducts[i].metadata.localizedDescription + "|" + tProducts[i].metadata.isoCurrencyCode);
|
||||
Product tItem = tProducts[i];
|
||||
if (tItem.definition.id.Equals(pID))
|
||||
{
|
||||
|
|
@ -356,10 +705,28 @@ public class IAPTool : NormalSingleton<IAPTool>, IStoreListener
|
|||
return "";
|
||||
}
|
||||
|
||||
public Product GetProductInfoByID(string pID)
|
||||
{
|
||||
if (m_StoreController == null && m_StoreExtensionProvider == null)
|
||||
return null;
|
||||
for (int i = 0; i < m_StoreController.products.all.Length; i++)
|
||||
{
|
||||
Product tItem = m_StoreController.products.all[i];
|
||||
if (tItem.definition.id.Equals(pID))
|
||||
{
|
||||
return tItem;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public SubscriptionInfo GetSubscriptionInfo()
|
||||
{
|
||||
return mSubsInfo;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -66,7 +66,7 @@ namespace Touka
|
|||
/// <param name="_adPos"> Name of interstitial ad placement. </param>
|
||||
/// <param name="_callback"> Callback of interstitial ad close and show interstitial failed</param>
|
||||
/// <param name="_IvType"> IVADType for distinguish interstitial ads frequency, default use iv1</param>
|
||||
void ShowInterstitialAd(TKGIVAdPositionName _adPos, Action _callback = null, IVADType _IvType = IVADType.IV1);
|
||||
void ShowInterstitialAd(string _adPos, Action _callback = null, IVADType _IvType = IVADType.IV1);
|
||||
|
||||
/// <summary>
|
||||
/// Show Reward Ad
|
||||
|
|
@ -74,7 +74,7 @@ namespace Touka
|
|||
/// <param name="_adPos"> Name of reward ad placement</param>
|
||||
/// <param name="_rewardCallback"> true:reward succ, false: reward failed</param>
|
||||
/// <param name="_showFailedCallback">Callback of reward ad show fail</param>
|
||||
void ShowRewardAd(TKGRVPositionName _adPos, Action<bool> _rewardCallback = null, Action _showFailedCallback = null);
|
||||
void ShowRewardAd(string _adPos, Action<bool> _rewardCallback = null, Action _showFailedCallback = null);
|
||||
|
||||
/// <summary>
|
||||
/// SetShowSDKToast
|
||||
|
|
@ -265,6 +265,13 @@ namespace Touka
|
|||
/// <param name="_gameFocusAction"></param>
|
||||
void SetUserSourceListener(Action<bool, string, string> _userSourceActionWithCampaignName);
|
||||
|
||||
/// <summary>
|
||||
/// 注册功能开关回调
|
||||
/// </summary>
|
||||
/// <param name="_functionKeys"> 各功能名称 </param>
|
||||
/// <param name="_functionSwitchCallback"> 回调事件,回来每个功能名称及对应开关 </param>
|
||||
void SetFunctionSwitchListener(List<FunctionType> _functionKeys, Action<FunctionType, bool> _functionSwitchCallback);
|
||||
|
||||
/// <summary>
|
||||
/// common callback
|
||||
/// </summary>
|
||||
|
|
@ -283,6 +290,26 @@ namespace Touka
|
|||
/// <param name="_shareTxt"></param>
|
||||
void ShareTxt(string _shareTxt);
|
||||
|
||||
/// <summary>
|
||||
/// show picture cross
|
||||
/// </summary>
|
||||
bool showPictureCross();
|
||||
|
||||
/// <summary>
|
||||
/// remove picture cross
|
||||
/// </summary>
|
||||
void removePictureCross();
|
||||
|
||||
/// <summary>
|
||||
/// show more game icon
|
||||
/// </summary>
|
||||
bool showMoreGameIcon();
|
||||
|
||||
/// <summary>
|
||||
/// remove more game icon
|
||||
/// </summary>
|
||||
void removeMoreGameIcon();
|
||||
|
||||
/// <summary>
|
||||
/// regist APNS
|
||||
/// </summary>
|
||||
|
|
@ -312,7 +339,225 @@ namespace Touka
|
|||
/// <param name="notiId">notification identifier</param>
|
||||
void RemoveNotification(string notiId);
|
||||
|
||||
/// <summary>
|
||||
/// if is debug mode
|
||||
/// </summary>
|
||||
bool IsDebugMode();
|
||||
|
||||
/// <summary>
|
||||
/// get user name and user id card
|
||||
/// </summary>
|
||||
string GetUserNameAndUserIDCard();
|
||||
|
||||
/// <summary>
|
||||
/// set segment type to sdk
|
||||
/// </summary>
|
||||
/// <param name="type">segment type</param>
|
||||
void SetSegment(SegmentType type);
|
||||
|
||||
/// <summary>
|
||||
/// get a iap product list for sdk config file
|
||||
/// </summary>
|
||||
Dictionary<string,string> GetIAPProductList();
|
||||
|
||||
#endregion
|
||||
|
||||
#region 数据中台
|
||||
void LogPurchasePrice(string price,string currency);
|
||||
|
||||
void LogRobuxCashOut();
|
||||
|
||||
void LogNoviceGuideFinish();
|
||||
|
||||
#endregion
|
||||
|
||||
#region GooglePlay评论引导
|
||||
/// <summary>
|
||||
/// Pop up GooglePlay Rate guid
|
||||
/// </summary>
|
||||
bool GuidGpComment();
|
||||
#endregion
|
||||
|
||||
#region 用户登录
|
||||
/// <summary>
|
||||
/// User Login
|
||||
/// <param name="_loginResultCallback">登录回调Action<登录状态码,登录类型,登录状态信息,userid,token,邮箱 , 显示名称 , 头像url></param>
|
||||
/// </summary>
|
||||
void Login(LoginType loginType, Action<LoginStatus, LoginType, string, string, string, string,string,string> _loginResultCallback = null);
|
||||
/// <summary>
|
||||
/// Logout
|
||||
/// </summary>
|
||||
void Logout(Action _logoutCallback = null);
|
||||
|
||||
/// <summary>
|
||||
/// Obtain a list of login channels,
|
||||
/// and the game displays the obtained login list for users to choose to log in.
|
||||
/// </summary>
|
||||
/// <returns>available login channels</returns>
|
||||
List<LoginType> AvailableLoginChannelList();
|
||||
|
||||
/// <summary>
|
||||
/// user actively deletes account.
|
||||
///
|
||||
/// Return the deleted userId. If the game needs to record it, you can operate it in the action.
|
||||
/// </summary>
|
||||
/// <param name="_deleteAccountCallback">Delete userId</param>
|
||||
void DeleteAccount(Action<DeleteStatus,string> _deleteAccountCallback = null);
|
||||
|
||||
void BindAccount(LoginType type, BindType isForce, string userId,
|
||||
Action<BindAccountStatus, LoginType, string, string, string, string, string, string, string[]>
|
||||
bindAccountCallback);
|
||||
|
||||
|
||||
|
||||
void AutoLogin(
|
||||
Action<LoginStatus, LoginType, string, string, string, string, string, string> loginResultCallback);
|
||||
|
||||
LoginType GetAccountType();
|
||||
|
||||
bool IsCanAutoLogin();
|
||||
|
||||
#endregion
|
||||
|
||||
#region IAP Event
|
||||
|
||||
/// <summary>
|
||||
/// Log IAP button show
|
||||
/// </summary>
|
||||
/// <param name="_productName">Product name (customized on the game side) English name of the product cannot contain special characters ex: Gem100</param>
|
||||
/// <param name="_productID">Product ID: The ID of a specific product type</param>
|
||||
void LogIAPBtnShow(string _productName,string _productID);
|
||||
|
||||
/// <summary>
|
||||
/// Log IAP button Click
|
||||
/// </summary>
|
||||
/// <param name="_productName">Product name (customized on the game side) English name of the product cannot contain special characters ex: Gem100</param>
|
||||
/// <param name="_productID">Product ID: The ID of a specific product type</param>
|
||||
void LogIAPBtnClick(string _productName, string _productID);
|
||||
|
||||
/// <summary>
|
||||
/// Log IAP First payment successful
|
||||
/// </summary>
|
||||
/// <param name="_iap">Product name (customized on the game side) English name of the product cannot contain special characters ex: Gem100</param>
|
||||
/// <param name="_id">Product ID: The ID of a specific product type</param>
|
||||
/// <param name="_paymentChannelOrderid">The order id returned by the payment channel</param>
|
||||
/// <param name="_currency">Currency ex:USD</param>
|
||||
/// <param name="_price">Price</param>
|
||||
void LogIAPFirstPurchase(string _iap, string _id,string _paymentChannelOrderid, string _currency, string _price);
|
||||
|
||||
/// <summary>
|
||||
/// Log IAP payment successful
|
||||
/// </summary>
|
||||
/// <param name="_iap">Product name (customized on the game side) English name of the product cannot contain special characters ex: Gem100</param>
|
||||
/// <param name="_id">Product ID: The ID of a specific product type</param>
|
||||
/// <param name="_gameOrderid">The order id on the game side</param>
|
||||
/// <param name="_paymentChannelOrderid">The order id returned by the payment channel</param>
|
||||
/// <param name="_productToken">Purchase token: When the purchase is successful on GP, a purchase token will be generated as a unique identifier</param>
|
||||
/// <param name="_paymentMethod">Official payment channels: appstore, googleplay, other payment channels corresponding channel name</param>
|
||||
/// <param name="_currency">Currency ex:USD</param>
|
||||
/// <param name="_price">Price</param>
|
||||
void LogIAPSuccess(string _iap, string _id, string _gameOrderid, string _paymentChannelOrderid, string _productToken, string _paymentMethod, string _currency, string _price);
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 保存数据
|
||||
void SaveCloudArchiving(string content, Action<int, string> callback);
|
||||
|
||||
void DetailCloudArchiving(Action<int, string> callback);
|
||||
#endregion
|
||||
}
|
||||
|
||||
public enum LoginType
|
||||
{
|
||||
// 游客登录
|
||||
LOGIN_BY_GUESTER = 0,
|
||||
|
||||
// 邮箱账号登录(暂不支持)
|
||||
LOGIN_BY_EMAIL = 1,
|
||||
|
||||
// Google登录
|
||||
LOGIN_BY_GOOGLE = 2,
|
||||
|
||||
// Facebook登录
|
||||
LOGIN_BY_FACEBOOK = 3,
|
||||
|
||||
LOGIN_BY_Apple = 4,
|
||||
|
||||
LOGIN_BY_AUTO = 10,
|
||||
}
|
||||
|
||||
|
||||
public enum BindAccountStatus
|
||||
{
|
||||
// 绑定失败
|
||||
BIND_CODE_FAILED = -1,
|
||||
// 绑定成功
|
||||
BIND_CODE_SUCC = 0,
|
||||
// 取消绑定
|
||||
BIND_CODE_CANCEL = 1,
|
||||
// 已经绑定账户,需要选择
|
||||
BIND_CODE_SELECT = 2,
|
||||
}
|
||||
|
||||
public enum BindType
|
||||
{
|
||||
NO_FORCE = 0,
|
||||
FORCE = 1,
|
||||
}
|
||||
|
||||
public enum DeleteStatus
|
||||
{
|
||||
DELETE_ACCOUNT_SUCC = 0,
|
||||
DELETE_ACCOUNT_CANCEL = 1,
|
||||
DELETE_ACCOUNT_FAILED = -1
|
||||
}
|
||||
|
||||
public enum LoginStatus
|
||||
{
|
||||
// 登录成功
|
||||
LOGIN_STATUS_SUCC = 0,
|
||||
|
||||
// 登录被用户取消
|
||||
LOGIN_STATUS_CANCEL = 1,
|
||||
|
||||
// 自动登陆没有缓存数据
|
||||
LOGIN_STATUS_NO_CACHE = 2,
|
||||
|
||||
// 登录失败
|
||||
LOGIN_STATUS_FAILED = -1
|
||||
}
|
||||
|
||||
public enum SegmentType
|
||||
{
|
||||
Purchase,
|
||||
T0,
|
||||
T1,
|
||||
T2,
|
||||
Other1,
|
||||
Other2,
|
||||
Other3,
|
||||
Other4,
|
||||
Other5,
|
||||
Other6,
|
||||
Other7,
|
||||
Other8,
|
||||
Other9
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 功能名称枚举
|
||||
/// </summary>
|
||||
public enum FunctionType
|
||||
{
|
||||
Function_wangz,
|
||||
Function_bing,
|
||||
Function_IA,
|
||||
Function_IP,
|
||||
Function_name,
|
||||
Function_other1,
|
||||
Function_other2,
|
||||
Function_other3
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -371,6 +616,11 @@ namespace Touka
|
|||
{
|
||||
FirebaseOnlineParamGet_Succ = 990001,
|
||||
FirebaseOnlineParamGet_Failed = 990002,
|
||||
|
||||
SaveCloudArchiving_Succ = 100,
|
||||
SaveCloudArchiving_Fail = 101,
|
||||
DetailCloudArchiving_Succ = 102,
|
||||
DetailCloudArchiving_Fail = 103,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -409,4 +659,28 @@ namespace Touka
|
|||
|
||||
AndroidRoot = 10000
|
||||
}
|
||||
|
||||
public enum AdsType
|
||||
{
|
||||
None,
|
||||
Banner,
|
||||
IV,
|
||||
RV,
|
||||
Native,
|
||||
Splash,
|
||||
}
|
||||
|
||||
public enum ThirdAccountType
|
||||
{
|
||||
None,
|
||||
Paypal
|
||||
}
|
||||
|
||||
public enum IAPClientFailReasonType
|
||||
{
|
||||
None,
|
||||
NotInit,
|
||||
PurchaseFailed,
|
||||
Deferred
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ namespace Touka
|
|||
/// <param name="_initCallback"></param>
|
||||
public void InitSDK(Action _initCallback = null)
|
||||
{
|
||||
TKGNativeInterface.Instance.Init(_initCallback);
|
||||
SetOnlineConfigInit();
|
||||
TKGNativeInterface.Instance.Init(_initCallback);
|
||||
}
|
||||
|
||||
private void SetOnlineConfigInit()
|
||||
|
|
@ -116,7 +116,7 @@ namespace Touka
|
|||
/// <param name="_adPos"> Name of interstitial ad placement. </param>
|
||||
/// <param name="_callback"> Callback of interstitial ad close and show interstitial failed</param>
|
||||
/// <param name="_IvType"> IVADType for distinguish interstitial ads frequency, default use iv1</param>
|
||||
public void ShowInterstitialAd(TKGIVAdPositionName _adPos, Action _callback = null, IVADType _IvType = IVADType.IV1)
|
||||
public void ShowInterstitialAd(string _adPos, Action _callback = null, IVADType _IvType = IVADType.IV1)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
TKGDebugger.LogDebug("[TKGSDKNative] Show Interstitial call, _adPos : " + _adPos);
|
||||
|
|
@ -124,7 +124,7 @@ namespace Touka
|
|||
return;
|
||||
#endif
|
||||
TKGSDKCallback.mInterAdCallback = _callback;
|
||||
TKGNativeInterface.Instance.showInterstitialAd(_adPos.ToString(), _IvType);
|
||||
TKGNativeInterface.Instance.showInterstitialAd(_adPos, _IvType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -133,7 +133,7 @@ namespace Touka
|
|||
/// <param name="_adPos"> Name of reward ad placement</param>
|
||||
/// <param name="_rewardCallback"> true:reward succ, false: reward failed</param>
|
||||
/// <param name="_showFailedCallback">Callback of reward ad show fail</param>
|
||||
public void ShowRewardAd(TKGRVPositionName _adPos, Action<bool> _rewardCallback = null, Action _showFailedCallback = null)
|
||||
public void ShowRewardAd(string _adPos, Action<bool> _rewardCallback = null, Action _showFailedCallback = null)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
TKGDebugger.LogDebug("[TKGSDKNative] Show reward call, _adPos : " + _adPos);
|
||||
|
|
@ -144,7 +144,7 @@ namespace Touka
|
|||
TKGSDKCallback.mRewardCallback = _rewardCallback;
|
||||
TKGSDKCallback.mRewardShowFailedCallback = _showFailedCallback;
|
||||
|
||||
TKGNativeInterface.Instance.showRewardAd(_adPos.ToString(), -1);
|
||||
TKGNativeInterface.Instance.showRewardAd(_adPos, -1);
|
||||
}
|
||||
|
||||
public void Toast(string text) {
|
||||
|
|
@ -443,13 +443,7 @@ namespace Touka
|
|||
{
|
||||
TKGDebugger.LogDebug("[TKGSDKNative] Review");
|
||||
#if UNITY_EDITOR
|
||||
#if AppStore_GB
|
||||
TKGDebugger.LogDebug("[TKGSDKNative] Review cannot be opened in editor, please open it in real machine");
|
||||
#else
|
||||
|
||||
TKGDebugger.LogDebug("[TKGSDKNative] 编辑器中无法打开评价页面,请在真机中打开");
|
||||
|
||||
#endif
|
||||
return;
|
||||
#endif
|
||||
TKGNativeInterface.Instance.Review();
|
||||
|
|
@ -462,13 +456,7 @@ namespace Touka
|
|||
{
|
||||
TKGDebugger.LogDebug("[TKGSDKNative] OpenPrivacyURL");
|
||||
#if UNITY_EDITOR
|
||||
#if AppStore_GB
|
||||
TKGDebugger.LogDebug("[TKGSDKNative] Web page cannot be opened in editor, please open it in real machine");
|
||||
#else
|
||||
|
||||
TKGDebugger.LogDebug("[TKGSDKNative] 编辑器中无法打开网页,请在真机中打开");
|
||||
|
||||
#endif
|
||||
return;
|
||||
#endif
|
||||
TKGNativeInterface.Instance.OpenPrivacyURL();
|
||||
|
|
@ -481,13 +469,7 @@ namespace Touka
|
|||
{
|
||||
TKGDebugger.LogDebug("[TKGSDKNative] OpenUserTermURL");
|
||||
#if UNITY_EDITOR
|
||||
#if AppStore_GB
|
||||
TKGDebugger.LogDebug("[TKGSDKNative] Web page cannot be opened in editor, please open it in real machine");
|
||||
#else
|
||||
|
||||
TKGDebugger.LogDebug("[TKGSDKNative] 编辑器中无法打开网页,请在真机中打开");
|
||||
|
||||
#endif
|
||||
return;
|
||||
#endif
|
||||
TKGNativeInterface.Instance.OpenUserTermURL();
|
||||
|
|
@ -500,13 +482,7 @@ namespace Touka
|
|||
{
|
||||
TKGDebugger.LogDebug("[TKGSDKNative] OpenPolicyPop");
|
||||
#if UNITY_EDITOR
|
||||
#if AppStore_GB
|
||||
TKGDebugger.LogDebug("[TKGSDKNative] Web page cannot be opened in editor, please open it in real machine");
|
||||
#else
|
||||
|
||||
TKGDebugger.LogDebug("[TKGSDKNative] 编辑器中无法打开网页,请在真机中打开");
|
||||
|
||||
#endif
|
||||
return;
|
||||
#endif
|
||||
TKGNativeInterface.Instance.OpenPolicyPop();
|
||||
|
|
@ -519,13 +495,7 @@ namespace Touka
|
|||
{
|
||||
TKGDebugger.LogDebug("[TKGSDKNative] OpenMoreGame");
|
||||
#if UNITY_EDITOR
|
||||
#if AppStore_GB
|
||||
TKGDebugger.LogDebug("[TKGSDKNative] App Store cannot be opened in editor, please open it in real machine");
|
||||
#else
|
||||
|
||||
TKGDebugger.LogDebug("[TKGSDKNative] 编辑器中无法打开App Store,请在真机中打开");
|
||||
|
||||
#endif
|
||||
return;
|
||||
#endif
|
||||
TKGNativeInterface.Instance.OpenMoreGame();
|
||||
|
|
@ -558,6 +528,35 @@ namespace Touka
|
|||
TKGNativeInterface.Instance.shake(_shakeType, _intensity);
|
||||
}
|
||||
|
||||
//
|
||||
public bool IsDebugMode()
|
||||
{
|
||||
return TKGNativeInterface.Instance.IsDebugMode();
|
||||
}
|
||||
|
||||
public string GetUserNameAndUserIDCard()
|
||||
{
|
||||
|
||||
return TKGNativeInterface.Instance.GetUserNameAndUserIDCard();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// set segment type to sdk
|
||||
/// </summary>
|
||||
/// <param name="type">segment type</param>
|
||||
public void SetSegment(SegmentType type)
|
||||
{
|
||||
TKGNativeInterface.Instance.SetSegment(type);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get a iap product list for sdk config file
|
||||
/// </summary>
|
||||
public Dictionary<string, string> GetIAPProductList()
|
||||
{
|
||||
return TKGNativeInterface.Instance.GetIAPProductList();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region others(uncommon)
|
||||
|
|
@ -588,6 +587,15 @@ namespace Touka
|
|||
TKGNativeInterface.Instance.SetUserSourceCallback(new AndroidTKGUserSourceCalllbackWithCampaignName());
|
||||
}
|
||||
|
||||
public void SetFunctionSwitchListener(List<FunctionType> _functionKeys, Action<FunctionType, bool> _functionSwitchCallback)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
return;
|
||||
#endif
|
||||
TKGSDKCallback.mFunctionSwitchCalllback = _functionSwitchCallback;
|
||||
TKGNativeInterface.Instance.SetFunctionSwitchCalllback(_functionKeys,new AndroidFunctionSwitchCalllback());
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Set TKG Common callback
|
||||
/// </summary>
|
||||
|
|
@ -623,6 +631,51 @@ namespace Touka
|
|||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// show picture cross
|
||||
/// </summary>
|
||||
public bool showPictureCross()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
return false;
|
||||
#endif
|
||||
return TKGNativeInterface.Instance.showPictureCross();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// remove picture cross
|
||||
/// </summary>
|
||||
public void removePictureCross()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
return;
|
||||
#endif
|
||||
TKGNativeInterface.Instance.removePictureCross();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// show more game icon
|
||||
/// </summary>
|
||||
public bool showMoreGameIcon()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
return false;
|
||||
#endif
|
||||
return TKGNativeInterface.Instance.showMoreGameIcon();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// remove more game icon
|
||||
/// </summary>
|
||||
public void removeMoreGameIcon()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
return;
|
||||
#endif
|
||||
TKGNativeInterface.Instance.removeMoreGameIcon();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// regist APNS
|
||||
/// </summary>
|
||||
|
|
@ -680,6 +733,111 @@ namespace Touka
|
|||
TKGNativeInterface.Instance.RemoveNotification(notiId);
|
||||
#endif
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region 数据中台
|
||||
|
||||
public void LogPurchasePrice(string price,string currency)
|
||||
{
|
||||
TKGNativeInterface.Instance.LogPurchasePrice(price,currency);
|
||||
}
|
||||
|
||||
public void LogRobuxCashOut()
|
||||
{
|
||||
TKGNativeInterface.Instance.LogRobuxCashOut();
|
||||
}
|
||||
|
||||
public void LogNoviceGuideFinish()
|
||||
{
|
||||
TKGNativeInterface.Instance.LogNoviceGuideFinish();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region GooglePlay评论引导
|
||||
/// <summary>
|
||||
/// Pop up GooglePlay Rate guid
|
||||
/// </summary>
|
||||
public bool GuidGpComment()
|
||||
{
|
||||
return TKGNativeInterface.Instance.GuidGpComment();
|
||||
}
|
||||
|
||||
public void Login(LoginType loginType, Action<LoginStatus, LoginType, string, string, string, string,string,string> _loginResultCallback = null)
|
||||
{
|
||||
TKGNativeInterface.Instance.Login(loginType, _loginResultCallback);
|
||||
}
|
||||
|
||||
public void Logout(Action _logoutCallback = null)
|
||||
{
|
||||
TKGNativeInterface.Instance.Logout(_logoutCallback);
|
||||
}
|
||||
|
||||
public List<LoginType> AvailableLoginChannelList()
|
||||
{
|
||||
return TKGNativeInterface.Instance.AvailableLoginChannelList();
|
||||
}
|
||||
|
||||
public void DeleteAccount(Action<DeleteStatus,string> deleteAccountCallback = null)
|
||||
{
|
||||
TKGNativeInterface.Instance.DeleteAccount(deleteAccountCallback);
|
||||
}
|
||||
|
||||
public void BindAccount(LoginType type,BindType isForce, string userId, Action<BindAccountStatus, LoginType, string, string, string, string, string, string, string[]> bindAccountCallback)
|
||||
{
|
||||
TKGNativeInterface.Instance.BindAccount(type, isForce, userId, bindAccountCallback);
|
||||
}
|
||||
|
||||
public void AutoLogin(Action<LoginStatus, LoginType, string, string, string, string, string, string> loginResultCallback)
|
||||
{
|
||||
TKGNativeInterface.Instance.AutoLogin(loginResultCallback);
|
||||
}
|
||||
|
||||
public LoginType GetAccountType()
|
||||
{
|
||||
return TKGNativeInterface.Instance.GetAccountType();
|
||||
}
|
||||
|
||||
public bool IsCanAutoLogin()
|
||||
{
|
||||
return TKGNativeInterface.Instance.IsCanAutoLogin();
|
||||
}
|
||||
|
||||
public void LogIAPBtnShow(string _productName, string _productID)
|
||||
{
|
||||
TKGNativeInterface.Instance.LogIAPBtnShow(_productName, _productID);
|
||||
}
|
||||
|
||||
public void LogIAPBtnClick(string _productName, string _productID)
|
||||
{
|
||||
TKGNativeInterface.Instance.LogIAPBtnClick(_productName, _productID);
|
||||
}
|
||||
|
||||
public void LogIAPFirstPurchase(string _iap, string _id, string _paymentChannelOrderid,string _currency, string _price)
|
||||
{
|
||||
TKGNativeInterface.Instance.LogIAPFirstPurchase(_iap, _id,_paymentChannelOrderid, _currency, _price);
|
||||
}
|
||||
|
||||
public void LogIAPSuccess(string _iap, string _id, string _gameOrderid, string _paymentChannelOrderid, string _productToken, string _paymentMethod, string _currency, string _price)
|
||||
{
|
||||
TKGNativeInterface.Instance.LogIAPSuccess(_iap,_id, _gameOrderid, _paymentChannelOrderid, _productToken, _paymentMethod, _currency, _price);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 保存数据
|
||||
|
||||
public void SaveCloudArchiving(string content, Action<int, string> callback)
|
||||
{
|
||||
TKGNativeInterface.Instance.SaveCloudArchiving(content, callback);
|
||||
}
|
||||
|
||||
public void DetailCloudArchiving(Action<int, string> callback)
|
||||
{
|
||||
TKGNativeInterface.Instance.DetailCloudArchiving(callback);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,21 +15,84 @@ public class TGiOSAdManager : MonoBehaviour
|
|||
public Action onAntiSuccessHander;
|
||||
private System.Action<bool, string> m_userSourceCallback;
|
||||
|
||||
public static TGiOSAdManager Instance
|
||||
public void LogPurchasePrice(string price,string currency)
|
||||
{
|
||||
get
|
||||
{
|
||||
if (s_instance == null)
|
||||
{
|
||||
GameObject TGGameObject = new GameObject
|
||||
{
|
||||
name = "AdObject"
|
||||
};
|
||||
s_instance = TGGameObject.AddComponent<TGiOSAdManager>();
|
||||
DontDestroyOnLoad(TGGameObject);
|
||||
TKG_DataCenter_Purchase(price);
|
||||
}
|
||||
return s_instance;
|
||||
|
||||
public void LogRobuxCashOut()
|
||||
{
|
||||
TKG_DataCenter_RobuxCashOut();
|
||||
}
|
||||
|
||||
public void LogNoviceGuideFinish()
|
||||
{
|
||||
TKG_DataCenter_Guide();
|
||||
}
|
||||
|
||||
public void setUserIDAndThirdAccount(string _userID, string _thirdAccount, ThirdAccountType _thirdAccountType)
|
||||
{
|
||||
TKG_SetUserIDAndThirdAccount(_userID,_thirdAccount, _thirdAccountType);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// get a iap product list for sdk config file
|
||||
/// </summary>
|
||||
public Dictionary<string, string> getIAPProductList()
|
||||
{
|
||||
|
||||
return StringToDictionary(TKG_GetIAPProductList());
|
||||
}
|
||||
|
||||
Dictionary<string, string> StringToDictionary(string value)
|
||||
{
|
||||
if (value.Length < 1)
|
||||
{
|
||||
return new Dictionary<string, string>();
|
||||
}
|
||||
Dictionary<string, string> dic = new Dictionary<string, string>();
|
||||
|
||||
string[] dicStrs = value.Split(',');
|
||||
foreach (string str in dicStrs)
|
||||
{
|
||||
string[] strs = str.Split('=');
|
||||
dic.Add(strs[0], strs[1]);
|
||||
}
|
||||
return dic;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// show picture cross
|
||||
/// </summary>
|
||||
public bool showPictureCross()
|
||||
{
|
||||
return TKG_ShowPictureCross();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// remove picture cross
|
||||
/// </summary>
|
||||
public void removePictureCross()
|
||||
{
|
||||
TKG_RemovePictureCross();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// show more game icon
|
||||
/// </summary>
|
||||
public bool showMoreGameIcon()
|
||||
{
|
||||
return TKG_ShowMoreGameIcon();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// remove more game icon
|
||||
/// </summary>
|
||||
public void removeMoreGameIcon()
|
||||
{
|
||||
TKG_RemoveMoreGameIcon();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -50,6 +113,11 @@ public class TGiOSAdManager : MonoBehaviour
|
|||
IntPtr us = Marshal.GetFunctionPointerForDelegate(usHandler);
|
||||
userSourceCallback(us);
|
||||
|
||||
// function Switch
|
||||
TKG_FunctionSwitchDelegate funcHandler = new TKG_FunctionSwitchDelegate(functionSwitchHandle);
|
||||
IntPtr func = Marshal.GetFunctionPointerForDelegate(funcHandler);
|
||||
funcSwitchCallback(func);
|
||||
|
||||
// rv close
|
||||
rewardCloseDelegate rvCloseHandler = new rewardCloseDelegate(rewardAdCloseHandle);
|
||||
IntPtr rewardClose = Marshal.GetFunctionPointerForDelegate(rvCloseHandler);
|
||||
|
|
@ -70,16 +138,32 @@ public class TGiOSAdManager : MonoBehaviour
|
|||
IntPtr rvClick = Marshal.GetFunctionPointerForDelegate(rvClickHandler);
|
||||
rewardAdClickCallback(rvClick);
|
||||
|
||||
revenueDelegate revenueHandler = new revenueDelegate(revenueHandle);
|
||||
IntPtr revHandle = Marshal.GetFunctionPointerForDelegate(revenueHandler);
|
||||
adsRevenreCallback(revHandle);
|
||||
|
||||
|
||||
TKG_InitSDK();
|
||||
|
||||
}
|
||||
|
||||
// 注册事件
|
||||
public void setFunctions(string funcs)
|
||||
{
|
||||
TKG_SetFuncs(funcs);
|
||||
}
|
||||
|
||||
// 通知
|
||||
public void registAPNS()
|
||||
{
|
||||
TKG_RegistAPNS();
|
||||
}
|
||||
|
||||
public string getUserNameAndUserIDCard()
|
||||
{
|
||||
return TKG_GetUserNameAndUserIDCard();
|
||||
}
|
||||
|
||||
public void registNotification(string notiId, string body, string fireDate, int badge, string title, string subTitle)
|
||||
{
|
||||
TKG_RegistNotification(notiId,body,fireDate,badge,title,subTitle);
|
||||
|
|
@ -100,11 +184,31 @@ public class TGiOSAdManager : MonoBehaviour
|
|||
TKG_Shake(mType,mIntensity);
|
||||
}
|
||||
|
||||
public bool isDebugMode()
|
||||
{
|
||||
return TKG_IsDebugMode();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// set segment type to sdk
|
||||
/// </summary>
|
||||
/// <param name="type">segment type</param>
|
||||
public void SetSegment(string type)
|
||||
{
|
||||
TKG_SetSegment(type);
|
||||
}
|
||||
|
||||
public void share(string _shareText)
|
||||
{
|
||||
TKG_Share(_shareText);
|
||||
}
|
||||
|
||||
// 获取渠道
|
||||
public int getChannel()
|
||||
{
|
||||
return TKG_GetChannel();
|
||||
}
|
||||
|
||||
// ads
|
||||
|
||||
public void RemoveAllAds()
|
||||
|
|
@ -367,6 +471,18 @@ public class TGiOSAdManager : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
// ad revenue callback
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void revenueDelegate(AdsType type,string price, string currency);
|
||||
[AOT.MonoPInvokeCallback(typeof(revenueDelegate))]
|
||||
static void revenueHandle(AdsType type, string price, string currency)
|
||||
{
|
||||
if (TKGSDKCallback.mAdsRevenueCallback != null)
|
||||
{
|
||||
TKGSDKCallback.mAdsRevenueCallback(type,price,currency);
|
||||
}
|
||||
}
|
||||
|
||||
// pause game
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void pauseGameDelegate(bool m_pause);
|
||||
|
|
@ -408,13 +524,124 @@ public class TGiOSAdManager : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
// set func
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void TKG_FunctionSwitchDelegate(string funcT, string funcS);
|
||||
[AOT.MonoPInvokeCallback(typeof(TKG_FunctionSwitchDelegate))]
|
||||
static void functionSwitchHandle(string funcType, string funcSwitch)
|
||||
{
|
||||
|
||||
Debug.Log("TKG GAME unity log 回调到unity里:"+funcType+"sw:"+funcSwitch);
|
||||
if (TKGSDKCallback.mFunctionSwitchCalllback != null)
|
||||
{
|
||||
FunctionType enumType = (FunctionType)Enum.Parse(typeof(FunctionType), funcType);
|
||||
|
||||
if (TKGSDKCallback.mFunctionSwitchCalllback != null)
|
||||
{
|
||||
bool res = funcSwitch == "1" ? true : false;
|
||||
TKGSDKCallback.mFunctionSwitchCalllback.Invoke(enumType, res);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// iap result callback
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void iapResultDelegate(string orderId, string productName,string productId,bool res,string gameExtre);
|
||||
[AOT.MonoPInvokeCallback(typeof(iapResultDelegate))]
|
||||
static void game_iapResultHandle(string orderId,string productName,string productId, bool reslut, string gameExtre)
|
||||
{
|
||||
if (TKGSDKCallback.mSecondPurchaseCallback != null)
|
||||
{
|
||||
TKGSDKCallback.mSecondPurchaseCallback(orderId,productName,productId, reslut, gameExtre);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// iap
|
||||
/// <summary>
|
||||
/// Client IAP Success
|
||||
/// </summary>
|
||||
public void IAP_ClientIAPSuccess(string _productName, string _productID, string _purchaseOrderID, string _purchaseToken, string _currency, string _price, string _gameExtra)
|
||||
{
|
||||
iapResultDelegate iapHandler = new iapResultDelegate(game_iapResultHandle);
|
||||
IntPtr iapRes = Marshal.GetFunctionPointerForDelegate(iapHandler);
|
||||
TKG_IapResultHandle(iapRes);
|
||||
|
||||
Dictionary<string, string> _productInfoDict = new Dictionary<string, string>();
|
||||
_productInfoDict.Add("iap_name", _productName);
|
||||
_productInfoDict.Add("product_id", _productID);
|
||||
_productInfoDict.Add("game_order_id", _gameExtra);
|
||||
_productInfoDict.Add("order_id", _purchaseOrderID);
|
||||
_productInfoDict.Add("purchase_token", _purchaseToken);
|
||||
_productInfoDict.Add("currency", _currency);
|
||||
_productInfoDict.Add("price", _price);
|
||||
TKG_ClientIAPSuccess(TKG_DictionaryToJson(_productInfoDict));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Client IAP Failed
|
||||
/// </summary>
|
||||
public void IAP_ClientIAPFailed(string _productName, string _productID, string _purchaseOrderID, string _purchaseToken, string _currency, string _price, string _gameExtra, IAPClientFailReasonType _failType)
|
||||
{
|
||||
iapResultDelegate iapHandler = new iapResultDelegate(game_iapResultHandle);
|
||||
IntPtr iapRes = Marshal.GetFunctionPointerForDelegate(iapHandler);
|
||||
TKG_IapResultHandle(iapRes);
|
||||
|
||||
Dictionary<string, string> _productInfoDict = new Dictionary<string, string>();
|
||||
_productInfoDict.Add("iap_name", _productName);
|
||||
_productInfoDict.Add("product_id", _productID);
|
||||
_productInfoDict.Add("game_order_id", _gameExtra);
|
||||
_productInfoDict.Add("order_id", _purchaseOrderID);
|
||||
_productInfoDict.Add("purchase_token", _purchaseToken);
|
||||
_productInfoDict.Add("currency", _currency);
|
||||
_productInfoDict.Add("price", _price);
|
||||
TKG_ClientIAPFailed(TKG_DictionaryToJson(_productInfoDict));
|
||||
}
|
||||
|
||||
|
||||
// dll
|
||||
[DllImport("__Internal")]
|
||||
private static extern void TKG_DataCenter_RobuxCashOut();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void TKG_DataCenter_Guide();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void TKG_DataCenter_Purchase(string price);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void TKG_SetSegment(string name);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern string TKG_GetIAPProductList();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern bool TKG_ShowPictureCross();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void TKG_RemovePictureCross();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern bool TKG_ShowMoreGameIcon();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void TKG_RemoveMoreGameIcon();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void TKG_SetFuncs(string funcs);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void TKG_Shake(int mType, float mIntensity);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern bool TKG_IsDebugMode();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void TKG_Share(string text);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern int TKG_GetChannel();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void TKG_InitSDK();
|
||||
|
||||
|
|
@ -476,6 +703,9 @@ public class TGiOSAdManager : MonoBehaviour
|
|||
[DllImport("__Internal")]
|
||||
private static extern void TKG_LoadIntersititial();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern string TKG_GetUserNameAndUserIDCard();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern bool TKG_IsReadyIntersititial();
|
||||
|
||||
|
|
@ -547,6 +777,11 @@ public class TGiOSAdManager : MonoBehaviour
|
|||
IntPtr rewardShowFail
|
||||
);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
public static extern void adsRevenreCallback(
|
||||
IntPtr adRevenue
|
||||
);
|
||||
|
||||
// pause game
|
||||
[DllImport("__Internal")]
|
||||
public static extern void pauseGameCallback(
|
||||
|
|
@ -565,6 +800,13 @@ public class TGiOSAdManager : MonoBehaviour
|
|||
IntPtr userSource
|
||||
);
|
||||
|
||||
// func callback
|
||||
[DllImport("__Internal")]
|
||||
public static extern void funcSwitchCallback(
|
||||
IntPtr funcSwitch
|
||||
);
|
||||
|
||||
|
||||
// 设置unity版本
|
||||
[DllImport("__Internal")]
|
||||
private static extern void TKG_SetUnityVersion(string version);
|
||||
|
|
@ -582,6 +824,22 @@ public class TGiOSAdManager : MonoBehaviour
|
|||
[DllImport("__Internal")]
|
||||
private static extern void TKG_RegistNotification(string notiId, string body, string fireDate, int badge, string title, string subTitle);
|
||||
|
||||
// iap
|
||||
[DllImport("__Internal")]
|
||||
private static extern void TKG_ClientIAPSuccess(string productInfo);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void TKG_ClientIAPFailed(string productInfo);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
public static extern void TKG_IapResultHandle(
|
||||
IntPtr iapResult
|
||||
);
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void TKG_SetUserIDAndThirdAccount(string _userID, string _thirdAccount, ThirdAccountType _thirdAccountType);
|
||||
|
||||
|
||||
// ============================ old sdk todo ========================
|
||||
|
||||
//设置log开关
|
||||
|
|
@ -594,6 +852,23 @@ public class TGiOSAdManager : MonoBehaviour
|
|||
{
|
||||
TKG_SetUnityVersion(version);
|
||||
}
|
||||
|
||||
public static TGiOSAdManager Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (s_instance == null)
|
||||
{
|
||||
GameObject TGGameObject = new GameObject
|
||||
{
|
||||
name = "AdObject"
|
||||
};
|
||||
s_instance = TGGameObject.AddComponent<TGiOSAdManager>();
|
||||
DontDestroyOnLoad(TGGameObject);
|
||||
}
|
||||
return s_instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -0,0 +1,235 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using Touka;
|
||||
using UnityEngine;
|
||||
|
||||
public class TKGiOSLoginManager : MonoBehaviour
|
||||
{
|
||||
#if UNITY_IOS
|
||||
// login result callback
|
||||
[DllImport("__Internal")]
|
||||
public static extern void TKG_LoginResultCallback(
|
||||
IntPtr loginResult
|
||||
);
|
||||
|
||||
// login out callback
|
||||
[DllImport("__Internal")]
|
||||
public static extern void TKG_LogoutCallback(
|
||||
IntPtr loginOut
|
||||
);
|
||||
|
||||
// delete account callback
|
||||
[DllImport("__Internal")]
|
||||
public static extern void TKG_DeleteAccountCallback(
|
||||
IntPtr deleteAccount
|
||||
);
|
||||
|
||||
// login out
|
||||
[DllImport("__Internal")]
|
||||
private static extern void TKG_Logout();
|
||||
|
||||
// availablechannel
|
||||
[DllImport("__Internal")]
|
||||
private static extern string TKG_AvailableLoginChannelList();
|
||||
|
||||
// login
|
||||
[DllImport("__Internal")]
|
||||
private static extern void TKG_Login(LoginType type);
|
||||
|
||||
// delete account
|
||||
[DllImport("__Internal")]
|
||||
private static extern void TKG_DeleteAccount();
|
||||
|
||||
|
||||
// bind account
|
||||
[DllImport("__Internal")]
|
||||
private static extern void TKG_BindAccount(LoginType loginType,BindType bindType,string thirdUid);
|
||||
|
||||
// bind account callback
|
||||
[DllImport("__Internal")]
|
||||
public static extern void TKG_BindAccountCallback(
|
||||
IntPtr bindAccount
|
||||
);
|
||||
|
||||
// auto login
|
||||
[DllImport("__Internal")]
|
||||
private static extern bool TKG_IsCanAutoLogin();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void TKG_AutoLogin();
|
||||
#endif
|
||||
|
||||
|
||||
public bool IsCanAutoLogin()
|
||||
{
|
||||
#if UNITY_IOS
|
||||
return TKG_IsCanAutoLogin();
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
public void AutoLogin()
|
||||
{
|
||||
#if UNITY_IOS
|
||||
// login callback
|
||||
loginResultDelegate loginResultHandler = new loginResultDelegate(loginResultHandle);
|
||||
IntPtr result = Marshal.GetFunctionPointerForDelegate(loginResultHandler);
|
||||
TKG_LoginResultCallback(result);
|
||||
TKG_AutoLogin();
|
||||
#endif
|
||||
}
|
||||
|
||||
public void DeleteAccount()
|
||||
{
|
||||
|
||||
#if UNITY_IOS
|
||||
// delete account callback
|
||||
deleteAccountDelegate deleteAccountHandler = new deleteAccountDelegate(deleteAccountHandle);
|
||||
IntPtr result = Marshal.GetFunctionPointerForDelegate(deleteAccountHandler);
|
||||
TKG_DeleteAccountCallback(result);
|
||||
|
||||
TKG_DeleteAccount();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
public void Login(LoginType _type)
|
||||
{
|
||||
#if UNITY_IOS
|
||||
// login callback
|
||||
loginResultDelegate loginResultHandler = new loginResultDelegate(loginResultHandle) ;
|
||||
IntPtr result = Marshal.GetFunctionPointerForDelegate(loginResultHandler);
|
||||
TKG_LoginResultCallback(result);
|
||||
|
||||
TKG_Login(_type);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
public void Logout()
|
||||
{
|
||||
#if UNITY_IOS
|
||||
// logout callback
|
||||
logoutDelegate logoutHandler = new logoutDelegate(logoutHandle);
|
||||
IntPtr result = Marshal.GetFunctionPointerForDelegate(logoutHandler);
|
||||
TKG_LogoutCallback(result);
|
||||
|
||||
TKG_Logout();
|
||||
#endif
|
||||
}
|
||||
|
||||
public List<LoginType> AvailableLoginChannelList()
|
||||
{
|
||||
|
||||
#if UNITY_EDITOR
|
||||
string temp = "0,4";
|
||||
#elif UNITY_IOS
|
||||
string temp = TKG_AvailableLoginChannelList();
|
||||
|
||||
|
||||
string[] arr = temp.Split(',');
|
||||
List<LoginType> list = new List<LoginType>();
|
||||
for (int i = 0; i < arr.Length; i++)
|
||||
{
|
||||
list.Add((LoginType)Enum.Parse(typeof(LoginType), arr[i]));
|
||||
}
|
||||
return list;
|
||||
#endif
|
||||
return null;
|
||||
}
|
||||
|
||||
public void BindAccount(LoginType loginType, BindType bindType, string thirdUid)
|
||||
{
|
||||
#if UNITY_IOS
|
||||
// logout callback
|
||||
bindAccountDelegate bindHandler = new bindAccountDelegate(bindAccountHandle);
|
||||
IntPtr result = Marshal.GetFunctionPointerForDelegate(bindHandler);
|
||||
TKG_BindAccountCallback(result);
|
||||
TKG_BindAccount(loginType,bindType,thirdUid);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if UNITY_IOS
|
||||
// bind account callback
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void bindAccountDelegate(BindAccountStatus status, LoginType type, string msg, string userId, string token, string email, string nickName, string iconUrl,string thirdUids);
|
||||
[AOT.MonoPInvokeCallback(typeof(bindAccountDelegate))]
|
||||
static void bindAccountHandle(BindAccountStatus status, LoginType type, string msg, string userId, string token, string email, string nickName, string iconUrl, string thirdUids)
|
||||
{
|
||||
|
||||
if (TKGSDKCallback.mBindAccountCallback != null)
|
||||
{
|
||||
string[] Strs = thirdUids.Split(',');
|
||||
TKGSDKCallback.mBindAccountCallback.Invoke(status, type, msg, userId, token, email, nickName, iconUrl, Strs);
|
||||
TKGSDKCallback.mBindAccountCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// delete account callback
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void deleteAccountDelegate(DeleteStatus status,string userId);
|
||||
[AOT.MonoPInvokeCallback(typeof(deleteAccountDelegate))]
|
||||
static void deleteAccountHandle(DeleteStatus status, string userId)
|
||||
{
|
||||
|
||||
if (TKGSDKCallback.mDeleteAccountCallback != null)
|
||||
{
|
||||
TKGSDKCallback.mDeleteAccountCallback.Invoke(status, userId);
|
||||
TKGSDKCallback.mDeleteAccountCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
// login out callback
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void logoutDelegate();
|
||||
[AOT.MonoPInvokeCallback(typeof(logoutDelegate))]
|
||||
static void logoutHandle()
|
||||
{
|
||||
|
||||
if (TKGSDKCallback.mLogoutCallback != null)
|
||||
{
|
||||
TKGSDKCallback.mLogoutCallback.Invoke();
|
||||
TKGSDKCallback.mLogoutCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
// login callback
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void loginResultDelegate(LoginStatus status, LoginType type, string msg, string userId, string token, string email, string nickName, string iconUrl);
|
||||
[AOT.MonoPInvokeCallback(typeof(loginResultDelegate))]
|
||||
static void loginResultHandle(LoginStatus status, LoginType type, string msg, string userId, string token, string email, string nickName, string iconUrl)
|
||||
{
|
||||
|
||||
if (TKGSDKCallback.mLoginCallback != null)
|
||||
{
|
||||
TKGSDKCallback.mLoginCallback.Invoke(status,type,msg,userId,token,email,nickName,iconUrl);
|
||||
TKGSDKCallback.mLoginCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
private static TKGiOSLoginManager s_instance;
|
||||
|
||||
public static TKGiOSLoginManager Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (s_instance == null)
|
||||
{
|
||||
GameObject TGGameObject = new GameObject
|
||||
{
|
||||
name = "TKGLoginObject"
|
||||
};
|
||||
s_instance = TGGameObject.AddComponent<TKGiOSLoginManager>();
|
||||
DontDestroyOnLoad(TGGameObject);
|
||||
}
|
||||
return s_instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4f7da094c07e543bcb390b93b01aba44
|
||||
guid: 5590242be350743f5af1a744a9e067ab
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
|
@ -1,16 +1,17 @@
|
|||
#if USE_IAP
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Purchasing;
|
||||
|
||||
public static class IAPProducts//商品ID统一小写
|
||||
public static class IAPProducts
|
||||
{
|
||||
public const string NoAds = "com.hotpotgames.lovepuzzle.global.noads";//去广告商品ID
|
||||
/// <summary>
|
||||
/// 去广告商品ID(商品ID统一小写)
|
||||
/// </summary>
|
||||
public const string NoAds = "mergegangster_noads";
|
||||
|
||||
public static readonly Dictionary<string, ProductType> ProductDic = new Dictionary<string, ProductType>()
|
||||
public readonly static Dictionary<string, ProductType> ProductDic = new Dictionary<string, ProductType>()
|
||||
{
|
||||
{ NoAds, ProductType.NonConsumable}
|
||||
{ NoAds, ProductType.NonConsumable},
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
|
@ -15,6 +15,8 @@ public enum TKGIVAdPositionName
|
|||
IV_Retry,
|
||||
IV_NextLevel,
|
||||
IV_Back,
|
||||
IV_Spin
|
||||
|
||||
}
|
||||
|
||||
public enum TKGNativePositionName
|
||||
|
|
@ -38,5 +40,6 @@ public enum TKGRVPositionName
|
|||
Get_Human,
|
||||
Get_Monster,
|
||||
Get_Coin,
|
||||
Get_AutoMerge,
|
||||
Get_AutoMerge
|
||||
|
||||
}
|
||||
|
|
@ -57,13 +57,22 @@ namespace Touka
|
|||
/// </summary>
|
||||
private static PlayerPrefPair[] ParseiOSConfigInner()
|
||||
{
|
||||
|
||||
|
||||
#if AppStore_GB
|
||||
PlayerPrefPair[] configs = TKGLoadPlistConfig.GetToukaConfig(toukaconfigFile,toukaconfigPathGB);
|
||||
#else
|
||||
PlayerPrefPair[] configs = TKGLoadPlistConfig.GetToukaConfig(toukaconfigFile, toukaconfigPathCN);
|
||||
#endif
|
||||
PlayerPrefPair[] configs = TKGLoadPlistConfig.GetToukaConfig(toukaconfigFile, toukaconfigPathGB);
|
||||
ParseConfigsInner(configs);
|
||||
return configs;
|
||||
#elif AppStore_CN
|
||||
PlayerPrefPair[] configs = TKGLoadPlistConfig.GetToukaConfig(toukaconfigFile, toukaconfigPathCN);
|
||||
ParseConfigsInner(configs);
|
||||
return configs;
|
||||
#else
|
||||
|
||||
return null;
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,382 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using Touka;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ToukaAccountSDKDemo : MonoBehaviour
|
||||
{
|
||||
public Transform loading;
|
||||
|
||||
public Transform loginView;
|
||||
|
||||
public Transform userCenter;
|
||||
|
||||
public Transform loginView_LoginChannelPanelRoot;
|
||||
|
||||
public Transform userCenter_loginType;
|
||||
public Transform userCenter_userId;
|
||||
public Transform userCenter_token;
|
||||
public Transform userCenter_userType;
|
||||
|
||||
public Transform btnBinded;
|
||||
public Transform btnBindGoogle;
|
||||
public Transform btnBindFacebook;
|
||||
|
||||
public Transform PanelUserCenter_BindSelect;
|
||||
|
||||
private string _userId;
|
||||
private string _token;
|
||||
private LoginType _userType;
|
||||
private LoginType _loginType;
|
||||
|
||||
private Action<LoginStatus, LoginType, string, string, string, string, string, string> _loginAction;
|
||||
|
||||
private Action<BindAccountStatus, LoginType, string, string, string, string, string, string, string[]>
|
||||
_bindAccountCallback;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
Loom.QueueOnMainThread((o => { }), "");
|
||||
TKGSDKManager.Instance.InitSDK(() => { });
|
||||
_loginAction = (status, type, msg, userid, token, email, displayName, photoUrl) =>
|
||||
{
|
||||
Debug.Log($"登陆回调 {status} type:{type} msg:{msg} userId:{userid} token:{token}");
|
||||
if (status == LoginStatus.LOGIN_STATUS_SUCC)
|
||||
{
|
||||
_userId = userid;
|
||||
_userType = type;
|
||||
_token = token;
|
||||
ShowUserCenter();
|
||||
ToukaToast.ShowToast("登陆成功");
|
||||
}
|
||||
else
|
||||
{
|
||||
_userId = "";
|
||||
_userType = LoginType.LOGIN_BY_GUESTER;
|
||||
_token = "";
|
||||
ToukaToast.ShowToast($"登陆失败:{msg}");
|
||||
ShowLoginView();
|
||||
}
|
||||
};
|
||||
|
||||
_bindAccountCallback = (status, loginTYpe, msg, userId, token, email, displayName, photoUrl, userIdList) =>
|
||||
{
|
||||
Debug.Log(
|
||||
$"绑定回调 {status} type:{loginTYpe} msg:{msg} userId:{userId} token:{token} userIdList:{userIdList}");
|
||||
if (status == BindAccountStatus.BIND_CODE_SELECT)
|
||||
{
|
||||
Debug.Log("绑定回调 - 选择界面");
|
||||
InitBindSelectView(userIdList);
|
||||
return;
|
||||
}
|
||||
|
||||
if (status == BindAccountStatus.BIND_CODE_SUCC)
|
||||
{
|
||||
Debug.Log("绑定回调 - 绑定成功");
|
||||
if (!userId.Equals(_userId))
|
||||
{
|
||||
Debug.Log($"绑定回调 - 绑定成功 - 重新登陆 userId:{userId} _userId:{_userId}");
|
||||
CloseBindSelectView();
|
||||
// 重新登陆了
|
||||
ShowLoading();
|
||||
return;
|
||||
}
|
||||
|
||||
ToukaToast.ShowToast("绑定成功");
|
||||
ShowUserCenter();
|
||||
return;
|
||||
}
|
||||
|
||||
ToukaToast.ShowToast($"绑定失败 {msg}");
|
||||
};
|
||||
ShowLoading();
|
||||
}
|
||||
|
||||
|
||||
private static void CreateButton(Transform rootViewTransform, string content, out Button myButton)
|
||||
{
|
||||
var rootVector2 = rootViewTransform.GetComponent<RectTransform>().sizeDelta;
|
||||
|
||||
// 创建一个Button对象
|
||||
var buttonGo = new GameObject("MyButton");
|
||||
myButton = buttonGo.AddComponent<Button>();
|
||||
var addComponent = buttonGo.AddComponent<RectTransform>();
|
||||
buttonGo.AddComponent<Image>();
|
||||
var sizeDelta = addComponent.sizeDelta;
|
||||
addComponent.sizeDelta = new Vector2(rootVector2.x, sizeDelta.y);
|
||||
// 设置Button的位置和大小
|
||||
myButton.transform.SetParent(rootViewTransform);
|
||||
myButton.transform.localPosition = Vector3.zero;
|
||||
myButton.transform.localScale = Vector3.one;
|
||||
|
||||
// image.sprite = Resources.Load("UISprite") as Sprite;
|
||||
|
||||
var textGo = new GameObject("Text");
|
||||
var text = textGo.AddComponent<Text>();
|
||||
var textRectTransform = textGo.GetComponent<RectTransform>();
|
||||
textRectTransform.anchorMin = new Vector2(0, 0);
|
||||
textRectTransform.anchorMax = new Vector2(1, 1);
|
||||
textRectTransform.pivot = new Vector2(0.5f, 0.5f);
|
||||
|
||||
|
||||
text.transform.SetParent(addComponent);
|
||||
textRectTransform.localPosition = new Vector3(0, 0, 0);
|
||||
textRectTransform.sizeDelta = new Vector2(0, 0);
|
||||
text.text = content;
|
||||
text.fontSize = 50;
|
||||
text.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
|
||||
text.alignment = TextAnchor.MiddleCenter;
|
||||
text.color = new Color(50 / 255f, 50 / 255f, 50 / 255f, 255 / 255f);
|
||||
}
|
||||
|
||||
private void InitBindSelectView(string[] userIdList)
|
||||
{
|
||||
userCenter.gameObject.SetActive(false);
|
||||
PanelUserCenter_BindSelect.gameObject.SetActive(true);
|
||||
|
||||
var rootViewTransform = PanelUserCenter_BindSelect.Find("BindListView");
|
||||
// foreach (Transform o in rootViewTransform)
|
||||
// {
|
||||
// Destroy(o.gameObject);
|
||||
// }
|
||||
|
||||
|
||||
foreach (var userId in userIdList)
|
||||
{
|
||||
var button = userId.Equals(_userId)
|
||||
? rootViewTransform.Find("Button_Bind_userId_current").GetComponent<Button>()
|
||||
: rootViewTransform.Find("Button_Bind_userId_other").GetComponent<Button>();
|
||||
|
||||
button.GetComponentInChildren<Text>().text = userId;
|
||||
|
||||
button.onClick.AddListener(() =>
|
||||
{
|
||||
TKGSDKManager.Instance.ForceBindAccount(userId, _bindAccountCallback);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void CloseBindSelectView()
|
||||
{
|
||||
PanelUserCenter_BindSelect.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
|
||||
private void ShowLoading()
|
||||
{
|
||||
CloseBindSelectView();
|
||||
loading.gameObject.SetActive(true);
|
||||
loginView.gameObject.SetActive(false);
|
||||
userCenter.gameObject.SetActive(false);
|
||||
InitShowLoading();
|
||||
}
|
||||
|
||||
private void InitShowLoading()
|
||||
{
|
||||
if (!TKGSDKManager.Instance.IsCanAutoLogin())
|
||||
{
|
||||
Debug.Log("显示登陆界面");
|
||||
ShowLoginView();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("发起自动登陆");
|
||||
new Thread(() =>
|
||||
{
|
||||
Thread.Sleep(1500);
|
||||
Loom.QueueOnMainThread(obj =>
|
||||
{
|
||||
_loginType = LoginType.LOGIN_BY_AUTO;
|
||||
TKGSDKManager.Instance.AutoLogin(_loginAction);
|
||||
}, "");
|
||||
}).Start();
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowLoginView()
|
||||
{
|
||||
CloseBindSelectView();
|
||||
loading.gameObject.SetActive(false);
|
||||
loginView.gameObject.SetActive(true);
|
||||
userCenter.gameObject.SetActive(false);
|
||||
InitLoginView();
|
||||
}
|
||||
|
||||
private void InitLoginView()
|
||||
{
|
||||
foreach (Transform o in loginView_LoginChannelPanelRoot)
|
||||
{
|
||||
Destroy(o.gameObject);
|
||||
}
|
||||
|
||||
foreach (var loginType in TKGSDKManager.Instance.AvailableLoginChannelList())
|
||||
{
|
||||
CreateButton(loginView_LoginChannelPanelRoot, LoginTypeToString(loginType), out var btn);
|
||||
btn.onClick.AddListener(() =>
|
||||
{
|
||||
_loginType = loginType;
|
||||
TKGSDKManager.Instance.Login(loginType, _loginAction);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowUserCenter()
|
||||
{
|
||||
CloseBindSelectView();
|
||||
loading.gameObject.SetActive(false);
|
||||
loginView.gameObject.SetActive(false);
|
||||
userCenter.gameObject.SetActive(true);
|
||||
InitShowUserCenter();
|
||||
}
|
||||
|
||||
private void InitShowUserCenter()
|
||||
{
|
||||
userCenter_userId.GetComponent<Text>().text = _userId;
|
||||
userCenter_token.GetComponent<Text>().text = _token;
|
||||
userCenter_userType.GetComponent<Text>().text = LoginTypeToString(_userType);
|
||||
userCenter_loginType.GetComponent<Text>().text = LoginTypeToString(_loginType);
|
||||
InitBindChannelView();
|
||||
}
|
||||
|
||||
private void InitBindChannelView()
|
||||
{
|
||||
btnBinded.gameObject.SetActive(false);
|
||||
btnBindFacebook.gameObject.SetActive(false);
|
||||
btnBindGoogle.gameObject.SetActive(false);
|
||||
if (TKGSDKManager.Instance.GetAccountType() == LoginType.LOGIN_BY_GUESTER)
|
||||
{
|
||||
foreach (var loginType in TKGSDKManager.Instance.AvailableLoginChannelList()
|
||||
.Where(loginType => loginType != LoginType.LOGIN_BY_GUESTER))
|
||||
{
|
||||
switch (loginType)
|
||||
{
|
||||
case LoginType.LOGIN_BY_FACEBOOK:
|
||||
btnBindFacebook.gameObject.SetActive(true);
|
||||
break;
|
||||
case LoginType.LOGIN_BY_GOOGLE:
|
||||
btnBindGoogle.gameObject.SetActive(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
btnBinded.gameObject.SetActive(true);
|
||||
btnBindFacebook.gameObject.SetActive(false);
|
||||
btnBindGoogle.gameObject.SetActive(false);
|
||||
}
|
||||
// if (TKGSDKManager.Instance.GetAccountType() == LoginType.LOGIN_BY_GUESTER)
|
||||
// {
|
||||
// userCenter_BindView.gameObject.SetActive(true);
|
||||
// foreach (Transform o in userCenter_BindChannelRoot)
|
||||
// {
|
||||
// Destroy(o.gameObject);
|
||||
// }
|
||||
//
|
||||
// foreach (var loginType in TKGSDKManager.Instance.AvailableLoginChannelList())
|
||||
// {
|
||||
// if (loginType == LoginType.LOGIN_BY_GUESTER)
|
||||
// {
|
||||
// continue;
|
||||
// }
|
||||
//
|
||||
// var myButton = Resources.Load<GameObject>("MyButton");
|
||||
// var instantiate = Instantiate(myButton, userCenter_BindChannelRoot);
|
||||
// var btn = instantiate.GetComponent<Button>();
|
||||
// btn.GetComponentInChildren<Text>().text = LoginTypeToString(loginType);
|
||||
// btn.onClick.AddListener(() => { TKGSDKManager.Instance.BindAccount(loginType, _bindAccountCallback); });
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// userCenter_BindView.gameObject.SetActive(false);
|
||||
// }
|
||||
}
|
||||
|
||||
public void OnClickLogout()
|
||||
{
|
||||
TKGSDKManager.Instance.Logout(ShowLoginView);
|
||||
}
|
||||
|
||||
public void OnClickDeleteAccount()
|
||||
{
|
||||
TKGSDKManager.Instance.DeleteAccount((status, s) =>
|
||||
{
|
||||
Debug.Log($"删除账号的回调: status : {status} s : {s}");
|
||||
if (status == DeleteStatus.DELETE_ACCOUNT_SUCC)
|
||||
{
|
||||
ToukaToast.ShowToast("删除账号的回调 - 退出游戏");
|
||||
ShowLoading();
|
||||
}
|
||||
else
|
||||
{
|
||||
ToukaToast.ShowToast("删除账号的回调 - 删除失败");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void OnClickSaveCloud()
|
||||
{
|
||||
var s = $"{_userId} - {_userType} - {_token}";
|
||||
|
||||
TKGSDKManager.Instance.SaveCloudArchiving(s,
|
||||
(status, msg) => { ToukaToast.ShowToast($"保存成功 : status : {status} msg : {msg}"); });
|
||||
}
|
||||
|
||||
public void OnClickDetailCloud()
|
||||
{
|
||||
TKGSDKManager.Instance.DetailCloudArchiving((status, msg) =>
|
||||
{
|
||||
ToukaToast.ShowToast($"获取信息成功 : status : {status} msg : {msg}");
|
||||
});
|
||||
}
|
||||
|
||||
public void OnClickBindGoogle()
|
||||
{
|
||||
TKGSDKManager.Instance.BindAccount(LoginType.LOGIN_BY_GOOGLE, _bindAccountCallback);
|
||||
}
|
||||
|
||||
public void OnClickBindFacebook()
|
||||
{
|
||||
TKGSDKManager.Instance.BindAccount(LoginType.LOGIN_BY_FACEBOOK, _bindAccountCallback);
|
||||
}
|
||||
public void OnClickGoScene()
|
||||
{
|
||||
SceneManager.LoadScene("ToukaSDKDemo");
|
||||
}
|
||||
|
||||
private string LoginTypeToString(LoginType loginType)
|
||||
{
|
||||
var res = "";
|
||||
|
||||
switch (loginType)
|
||||
{
|
||||
case LoginType.LOGIN_BY_GUESTER:
|
||||
res = "guester";
|
||||
break;
|
||||
case LoginType.LOGIN_BY_EMAIL:
|
||||
res = "email";
|
||||
break;
|
||||
case LoginType.LOGIN_BY_GOOGLE:
|
||||
res = "google";
|
||||
break;
|
||||
case LoginType.LOGIN_BY_FACEBOOK:
|
||||
res = "facebook";
|
||||
break;
|
||||
case LoginType.LOGIN_BY_Apple:
|
||||
res = "apple";
|
||||
break;
|
||||
case LoginType.LOGIN_BY_AUTO:
|
||||
res = "auto";
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(loginType), loginType, null);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e53c756d6293540f1b613f79d3c1b317
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 95ff3bf0595fe4eb8853263ffb87d214
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,23 +1,62 @@
|
|||
using System.Collections;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
#if USE_IAP
|
||||
using UnityEngine.Purchasing;
|
||||
#endif
|
||||
using UnityEngine.UI;
|
||||
|
||||
|
||||
namespace Touka
|
||||
{
|
||||
public class ToukaSDKDemo : MonoBehaviour
|
||||
{
|
||||
|
||||
|
||||
public Image nativeImage;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
InitSDK();
|
||||
|
||||
SetFunctionSwitchListener();
|
||||
}
|
||||
|
||||
#region Init
|
||||
#region function swtich listener
|
||||
|
||||
// set function switch listener
|
||||
private void SetFunctionSwitchListener()
|
||||
{
|
||||
List<FunctionType> list = new List<FunctionType>();
|
||||
list.Add(FunctionType.Function_bing);
|
||||
list.Add(FunctionType.Function_IA);
|
||||
|
||||
//TKGSDKManager.Instance.SetFunctionSwitchListener(list, OnFunsSwitchCallback);
|
||||
|
||||
TKGSDKManager.Instance.SetFunctionSwitchListener(new List<Touka.FunctionType>() { FunctionType.Function_wangz, FunctionType.Function_bing }, OnFunsSwitchCallback);
|
||||
}
|
||||
|
||||
private void OnFunsSwitchCallback(FunctionType _type, bool result)
|
||||
{
|
||||
Debug.Log("[ToukaSDKDemo]:FunctionType:" + _type + "result:" + result);
|
||||
if (_type == FunctionType.Function_wangz)
|
||||
{
|
||||
|
||||
}
|
||||
else if(_type == FunctionType.Function_bing)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public void removeNativeAd()
|
||||
{
|
||||
TKGSDKManager.Instance.RemoveNative();
|
||||
}
|
||||
|
||||
public void OnShowNativeAd()
|
||||
{
|
||||
|
|
@ -27,9 +66,12 @@ namespace Touka
|
|||
public void OnButton_Init()
|
||||
{
|
||||
Debug.Log("[ToukaSDKDemo] OnButton_Init click, InitSDK auto Callfirst");
|
||||
|
||||
InitSDK();
|
||||
}
|
||||
|
||||
|
||||
#region Init
|
||||
|
||||
private void InitSDK()
|
||||
{
|
||||
OnButton_UserSource();
|
||||
|
|
@ -38,12 +80,25 @@ namespace Touka
|
|||
TKGSDKManager.Instance.InitSDK(initCallback);
|
||||
TKGSDKManager.Instance.SetLogEnable(true);
|
||||
TKGSDKManager.Instance.SetRewardClickListener(ClickRewardCallback);
|
||||
TKGSDKManager.Instance.SetAdsRevenueCallback(AdsRevenueCallback);
|
||||
}
|
||||
|
||||
private void ClickRewardCallback()
|
||||
{
|
||||
Debug.Log("[ToukaSDKDemo] click reward callback");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ads Revenue callback
|
||||
/// </summary>
|
||||
/// <param name="_adsType"></param>
|
||||
/// <param name="_price"></param>
|
||||
/// <param name=""></param>
|
||||
private void AdsRevenueCallback(AdsType _adsType, string _price, string _currency)
|
||||
{
|
||||
Debug.Log("AdsRevenueCallback, _adsType : " + _adsType + " , _price : " + _price + " , _currency : " + _currency);
|
||||
}
|
||||
|
||||
private void initCallback()
|
||||
{
|
||||
Debug.Log("[ToukaSDKDemo] init callback");
|
||||
|
|
@ -62,7 +117,16 @@ namespace Touka
|
|||
public void OnButton_ShowInterstitialAd()
|
||||
{
|
||||
Debug.Log("[ToukaSDKDemo] OnButton_ShowInterstitialAd click");
|
||||
TKGSDKManager.Instance.ShowInterstitialAd(TKGIVAdPositionName.IV_Retry, IVCallback);
|
||||
|
||||
|
||||
TKGSDKManager.Instance.ShowInterstitialAd(TKGIVAdPositionName.IV_Spin, IVCallback);
|
||||
|
||||
|
||||
Dictionary<string,string> dic = TKGSDKManager.Instance.GetIAPProductList();
|
||||
foreach (var item in dic)
|
||||
{
|
||||
Debug.Log("dic key:"+item.Key+",value:"+item.Value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -227,6 +291,35 @@ namespace Touka
|
|||
TKGSDKManager.Instance.Review();
|
||||
}
|
||||
|
||||
public void OnButton_showPictureCross()
|
||||
{
|
||||
Debug.Log("[ToukaSDKDemo] OnButton_showPictureCross click");
|
||||
TKGSDKManager.Instance.showPictureCross();
|
||||
}
|
||||
|
||||
public void OnButton_removePictureCross()
|
||||
{
|
||||
Debug.Log("[ToukaSDKDemo] OnButton_removePictureCross click");
|
||||
TKGSDKManager.Instance.removePictureCross();
|
||||
}
|
||||
|
||||
public void OnButton_showMoreGameIcon()
|
||||
{
|
||||
Debug.Log("[ToukaSDKDemo] OnButton_showMoreGameIcon click");
|
||||
TKGSDKManager.Instance.showMoreGameIcon();
|
||||
}
|
||||
|
||||
public void OnButton_removeMoreGameIcon()
|
||||
{
|
||||
Debug.Log("[ToukaSDKDemo] OnButton_removeMoreGameIcon click");
|
||||
TKGSDKManager.Instance.removeMoreGameIcon();
|
||||
}
|
||||
|
||||
public void OnButton_GuidGpComment()
|
||||
{
|
||||
Debug.Log("[ToukaSDKDemo] OnButton_GuidGpComment click");
|
||||
TKGSDKManager.Instance.GuidGpComment();
|
||||
}
|
||||
|
||||
public void OnButton_SetGameFocusListener()
|
||||
{
|
||||
|
|
@ -302,5 +395,118 @@ namespace Touka
|
|||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 用户登录
|
||||
public void Login()
|
||||
{
|
||||
SceneManager.LoadScene("ToukaAccountSDKDemo");
|
||||
}
|
||||
|
||||
public void Logout()
|
||||
{
|
||||
TKGSDKManager.Instance.Logout(null);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IAP Event
|
||||
|
||||
/// <summary>
|
||||
/// Log IAP button show
|
||||
/// </summary>
|
||||
public void LogIAPBtnShow()
|
||||
{
|
||||
TKGSDKManager.Instance.LogIAPBtnShow("Gem100","com.xx.gem100");
|
||||
}
|
||||
|
||||
//#if USE_IAP
|
||||
|
||||
/// <summary>
|
||||
/// 购买商品
|
||||
/// </summary>
|
||||
public void BuyProduct()
|
||||
{
|
||||
// 设置回调
|
||||
TKGSDKManager.Instance.SetOnPurchaseDone(OnPurchaseResult);
|
||||
string productID = "com.tkkk.unitysdk.demo.a1";
|
||||
string productName = "a1";
|
||||
string gameExtra = "a1GameExtraParam";
|
||||
Debug.Log("[ToukaSDKDemo] ButProduct clickProductID: " + productID);
|
||||
#if USE_IAP
|
||||
TKGSDKManager.Instance.BuyProductByID(productID, productName, gameExtra);
|
||||
#endif
|
||||
}
|
||||
#if USE_IAP
|
||||
public void OnGetProductsInfo(Product[] products)
|
||||
{
|
||||
foreach (var product in products)
|
||||
{
|
||||
TKGDebugger.LogDebug("[ToukaSDKDemo] "+product.metadata.localizedTitle
|
||||
+ "|" + product.metadata.localizedPriceString
|
||||
+ "|" + product.metadata.localizedDescription
|
||||
+ "|" + product.metadata.isoCurrencyCode);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
public void OnPurchaseDone(string procuctID,bool isSucc,string orderID,string token)
|
||||
{
|
||||
if (isSucc)
|
||||
{
|
||||
//add gold
|
||||
TKGDebugger.LogDebug("[ToukaSDKDemo] Pay success,add gold, procuctID : " + procuctID + " , isSucc : " + isSucc + " , orderID :" + orderID + ", ");
|
||||
}
|
||||
else
|
||||
{
|
||||
// purchase failed
|
||||
TKGDebugger.LogDebug("[ToukaSDKDemo] Pay success,add gold");
|
||||
}
|
||||
}
|
||||
|
||||
public void AddProducts()
|
||||
{
|
||||
#if USE_IAP
|
||||
Dictionary<string, ProductType> products = new Dictionary<string, ProductType>();
|
||||
products.Add("com.tkkk.unitysdk.demo.a1",ProductType.NonConsumable);
|
||||
products.Add("com.tkkk.unitysdk.demo.a12",ProductType.NonConsumable);
|
||||
products.Add("com.magicalcreatures.gems8",ProductType.NonConsumable);
|
||||
products.Add("com.magicalcreatures.newpackage1",ProductType.NonConsumable);
|
||||
TKGSDKManager.Instance.AddProducts(products);
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 购买后面添加的商品
|
||||
/// </summary>
|
||||
public void BuyProduct2()
|
||||
{
|
||||
// 设置回调
|
||||
TKGSDKManager.Instance.SetOnPurchaseDone(OnPurchaseResult);
|
||||
// string productID = "com.tkkk.unitysdk.demo.a12";
|
||||
string productID = "com.magicalcreatures.gems8";
|
||||
string productName = "a12";
|
||||
string gameExtra = "a12GameExtraParam";
|
||||
Debug.Log("[ToukaSDKDemo] ButProduct2 click :ProductID: "+ productID);
|
||||
#if USE_IAP
|
||||
TKGSDKManager.Instance.BuyProductByID(productID, productName, gameExtra);
|
||||
#endif
|
||||
}
|
||||
|
||||
private void OnPurchaseResult(string pOrderID, string pProductName, string pID, bool pResult, string gameExtra)
|
||||
{
|
||||
Debug.Log("[ToukaSDKDemo] ButProduct pOrderID:"+ pOrderID + " pProductName:"+ pProductName + " pID:"+ pID + " OnPurchaseResult:" + pResult + " , gameExtra : " + gameExtra);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region for wz
|
||||
|
||||
/// <summary>
|
||||
/// SetUserIDAndThirdAccount
|
||||
/// </summary>
|
||||
public void SetUserIDAndThirdAccountBtnClick()
|
||||
{
|
||||
TKGSDKManager.Instance.SetUserIDAndThirdAccount("TK_001", "paypal_a001", ThirdAccountType.Paypal);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,53 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Touka
|
||||
{
|
||||
public class ToukaToast : MonoBehaviour
|
||||
{
|
||||
private static ToukaToast instance;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (instance != null)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
else
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
instance.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public static ToukaToast Instance => instance;
|
||||
|
||||
public Text toastText;
|
||||
private const float ToastDuration = 2f;
|
||||
|
||||
public static void ShowToast(string message)
|
||||
{
|
||||
instance._ShowToast(message);
|
||||
}
|
||||
|
||||
private void _ShowToast(string message)
|
||||
{
|
||||
instance.gameObject.SetActive(true);
|
||||
StartCoroutine(ShowAndHideToast(message));
|
||||
}
|
||||
|
||||
private IEnumerator ShowAndHideToast(string message)
|
||||
{
|
||||
toastText.text = message;
|
||||
instance.gameObject.SetActive(true);
|
||||
yield return new WaitForSeconds(ToastDuration);
|
||||
instance.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 22422e2c982f40adae82313af9a1ebff
|
||||
timeCreated: 1690771262
|
||||
|
|
@ -15,12 +15,12 @@ namespace Touka
|
|||
public static void OnPostprocessBuild(BuildTarget buildTarget, string path)
|
||||
{
|
||||
if (buildTarget != BuildTarget.iOS) return;
|
||||
|
||||
#if UNITY_IOS
|
||||
ModifyURLTypes(path);
|
||||
ModifyCode(path);
|
||||
#if AppStore_CN
|
||||
ModifyBundle(path);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -35,29 +35,44 @@ namespace Touka
|
|||
|
||||
plist.root.SetBoolean("GADIsAdManagerApp", true);
|
||||
|
||||
#if !AppStore_GB
|
||||
#if AppStore_CN
|
||||
plist.root.SetString("GADApplicationIdentifier", TKGLoadConfig.GetConfigByKey(ConfigKeys.KEY_Admob_AppID, AppChannel.AppStore_CN));
|
||||
plist.root.SetString("AppId", TKGLoadConfig.GetConfigByKey(ConfigKeys.KEY_TOUKA_SDK_APPID, AppChannel.AppStore_CN));
|
||||
|
||||
plist.root.SetString("AppKey", TKGLoadConfig.GetConfigByKey(ConfigKeys.KEY_TOUKA_SDK_APPKEY, AppChannel.AppStore_CN) );
|
||||
plist.root.SetString("splashPlacement", TKGLoadConfig.GetConfigByKey(ConfigKeys.KEY_TOUKA_SDK_SPLASHID, AppChannel.AppStore_CN));
|
||||
|
||||
|
||||
#else
|
||||
#elif AppStore_GB
|
||||
plist.root.SetString("GADApplicationIdentifier", TKGLoadConfig.GetConfigByKey(ConfigKeys.KEY_Admob_AppID, AppChannel.AppStore_GB));
|
||||
plist.root.SetString("AppLovinSdkKey", TKGLoadConfig.GetConfigByKey(ConfigKeys.KEY_TOUKA_SDK_APPKEY, AppChannel.AppStore_GB));
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
plist.root.SetBoolean("ITSAppUsesNonExemptEncryption", false);
|
||||
|
||||
//NSAppTransportSecurity set yes
|
||||
string pPath = Path.Combine(_path, "Info.plist");
|
||||
if (File.Exists(plistPath))
|
||||
{
|
||||
PlistDocument doc = new PlistDocument();
|
||||
doc.ReadFromFile(plistPath);
|
||||
PlistElementDict rootDict = doc.root.AsDict();
|
||||
if (rootDict != null)
|
||||
{
|
||||
if (rootDict["NSAppTransportSecurity"] != null)
|
||||
{
|
||||
|
||||
PlistElementDict atf = plist.root["NSAppTransportSecurity"].AsDict();
|
||||
atf.SetBoolean("NSAllowsArbitraryLoads", true);
|
||||
}
|
||||
|
||||
#region iOS 14
|
||||
//SKAdnetwork追加
|
||||
doc.WriteToFile(plistPath);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region iOS 14
|
||||
PlistElementArray URLWhiteListArr2 = plist.root.CreateArray("SKAdNetworkItems");
|
||||
|
||||
//admob (1)
|
||||
|
|
@ -637,6 +652,51 @@ namespace Touka
|
|||
dic139 = URLWhiteListArr2.AddDict();
|
||||
dic139.SetString("SKAdNetworkIdentifier", "x5l83yy675.skadnetwork");
|
||||
|
||||
|
||||
PlistElementDict dic140;
|
||||
dic140 = URLWhiteListArr2.AddDict();
|
||||
dic140.SetString("SKAdNetworkIdentifier", "6p4ks3rnbw.skadnetwork");
|
||||
|
||||
PlistElementDict dic141;
|
||||
dic141 = URLWhiteListArr2.AddDict();
|
||||
dic141.SetString("SKAdNetworkIdentifier", "a2p9lx4jpn.skadnetwork");
|
||||
|
||||
PlistElementDict dic142;
|
||||
dic142 = URLWhiteListArr2.AddDict();
|
||||
dic142.SetString("SKAdNetworkIdentifier", "bxvub5ada5.skadnetwork");
|
||||
|
||||
PlistElementDict dic143;
|
||||
dic143 = URLWhiteListArr2.AddDict();
|
||||
dic143.SetString("SKAdNetworkIdentifier", "s69wq72ugq.skadnetwork");
|
||||
|
||||
PlistElementDict dic144;
|
||||
dic144 = URLWhiteListArr2.AddDict();
|
||||
dic144.SetString("SKAdNetworkIdentifier", "47vhws6wlr.skadnetwork");
|
||||
|
||||
PlistElementDict dic145;
|
||||
dic145 = URLWhiteListArr2.AddDict();
|
||||
dic145.SetString("SKAdNetworkIdentifier", "a2p9lx4jpn.skadnetwork");
|
||||
|
||||
PlistElementDict dic146;
|
||||
dic146 = URLWhiteListArr2.AddDict();
|
||||
dic146.SetString("SKAdNetworkIdentifier", "cp8zw746q7.skadnetwork");
|
||||
|
||||
PlistElementDict dic147;
|
||||
dic147 = URLWhiteListArr2.AddDict();
|
||||
dic147.SetString("SKAdNetworkIdentifier", "y5ghdn5j9k.skadnetwork");
|
||||
|
||||
PlistElementDict dic148;
|
||||
dic148 = URLWhiteListArr2.AddDict();
|
||||
dic148.SetString("SKAdNetworkIdentifier", "a2p9lx4jpn.skadnetwork");
|
||||
|
||||
PlistElementDict dic149;
|
||||
dic149 = URLWhiteListArr2.AddDict();
|
||||
dic149.SetString("SKAdNetworkIdentifier", "nu4557a4je.skadnetwork");
|
||||
|
||||
PlistElementDict dic150;
|
||||
dic150 = URLWhiteListArr2.AddDict();
|
||||
dic150.SetString("SKAdNetworkIdentifier", "8r8llnkz5a.skadnetwork");
|
||||
|
||||
#endregion
|
||||
|
||||
PlistElementArray urlTypes = plist.root.CreateArray("CFBundleURLTypes");
|
||||
|
|
@ -646,12 +706,64 @@ namespace Touka
|
|||
PlistElementArray schemesArray = dict.CreateArray("CFBundleURLSchemes");
|
||||
schemesArray.AddString(Application.identifier);
|
||||
|
||||
|
||||
#if AppStore_GB
|
||||
PlistElementDict dict1 = urlTypes.AddDict();
|
||||
dict1.SetString("CFBundleURLName", "um");
|
||||
PlistElementArray schemesArray1 = dict1.CreateArray("CFBundleURLSchemes");
|
||||
schemesArray1.AddString("um."+ TKGLoadConfig.GetConfigByKey(ConfigKeys.KEY_UMENG_APPKEY, AppChannel.AppStore_GB));
|
||||
#elif AppStore_CN
|
||||
PlistElementDict dict1 = urlTypes.AddDict();
|
||||
dict1.SetString("CFBundleURLName", "um");
|
||||
PlistElementArray schemesArray1 = dict1.CreateArray("CFBundleURLSchemes");
|
||||
schemesArray1.AddString("um." + TKGLoadConfig.GetConfigByKey(ConfigKeys.KEY_UMENG_APPKEY, AppChannel.AppStore_CN));
|
||||
#endif
|
||||
|
||||
PlistElementArray QueriesSchemes = plist.root.CreateArray("LSApplicationQueriesSchemes");
|
||||
QueriesSchemes.AddString("openapp.jdmobile");
|
||||
QueriesSchemes.AddString("vipshop");
|
||||
QueriesSchemes.AddString("tbopen");
|
||||
QueriesSchemes.AddString("tmall");
|
||||
QueriesSchemes.AddString("suning");
|
||||
QueriesSchemes.AddString("ctrip");
|
||||
QueriesSchemes.AddString("qunariphone");
|
||||
QueriesSchemes.AddString("imeituan");
|
||||
QueriesSchemes.AddString("dianping");
|
||||
QueriesSchemes.AddString("lianjia");
|
||||
QueriesSchemes.AddString("pddopen");
|
||||
QueriesSchemes.AddString("xhsdiscover");
|
||||
QueriesSchemes.AddString("baiduhaokan");
|
||||
QueriesSchemes.AddString("bdminivideo");
|
||||
QueriesSchemes.AddString("baiduboxlite");
|
||||
QueriesSchemes.AddString("baiduboxmission");
|
||||
QueriesSchemes.AddString("com.baidu.tieba");
|
||||
QueriesSchemes.AddString("zhihu");
|
||||
QueriesSchemes.AddString("wireless1688");
|
||||
QueriesSchemes.AddString("iqiyi");
|
||||
QueriesSchemes.AddString("weixin");
|
||||
QueriesSchemes.AddString("qihooloan");
|
||||
QueriesSchemes.AddString("weishi");
|
||||
QueriesSchemes.AddString("travelguide");
|
||||
QueriesSchemes.AddString("wbmain");
|
||||
QueriesSchemes.AddString("taobaotravel");
|
||||
QueriesSchemes.AddString("kwai");
|
||||
QueriesSchemes.AddString("ksnebula");
|
||||
QueriesSchemes.AddString("sinaweibo");
|
||||
QueriesSchemes.AddString("alipays");
|
||||
QueriesSchemes.AddString("youku");
|
||||
QueriesSchemes.AddString("openjdlite");
|
||||
QueriesSchemes.AddString("com.360buy.jdpingou");
|
||||
QueriesSchemes.AddString("cainiao");
|
||||
QueriesSchemes.AddString("kaola");
|
||||
QueriesSchemes.AddString("OneTravel");
|
||||
QueriesSchemes.AddString("lianjiabeike");
|
||||
QueriesSchemes.AddString("iosamap");
|
||||
|
||||
File.WriteAllText(plistPath, plist.WriteToString());
|
||||
}
|
||||
|
||||
private static void ModifyBundle(string _path)
|
||||
{
|
||||
#if !AppStore_GB
|
||||
string projectPath = PBXProject.GetPBXProjectPath(_path);
|
||||
|
||||
PBXProject pbxProject = new PBXProject();
|
||||
|
|
@ -665,26 +777,32 @@ namespace Touka
|
|||
#endif
|
||||
pbxProject.AddFileToBuild(mainTarget, pbxProject.AddFile("Frameworks/Plugins/ToukaGames/Plugins/iOS/ToponSDK/Core/AnyThinkSDK.bundle", "Frameworks/Plugins/ToukaGames/Plugins/iOS/ToponSDK/Core/AnyThinkSDK.bundle", PBXSourceTree.Sdk));
|
||||
pbxProject.AddFileToBuild(mainTarget, pbxProject.AddFile("Frameworks/Plugins/ToukaGames/Plugins/iOS/ToponSDK/pangle_China/CSJAdSDK.bundle", "Frameworks/Plugins/ToukaGames/Plugins/iOS/ToponSDK/pangle_China/CSJAdSDK.bundle", PBXSourceTree.Sdk));
|
||||
//pbxProject.AddFileToBuild(mainTarget, pbxProject.AddFile("Frameworks/Plugins/ToukaGames/Plugins/iOS/ToponSDK/pangle_China/BUAdSDK.bundle", "Frameworks/Plugins/ToukaGames/Plugins/iOS/ToponSDK/pangle_China/BUAdSDK.bundle", PBXSourceTree.Sdk));
|
||||
|
||||
pbxProject.WriteToFile(projectPath);
|
||||
#endif
|
||||
}
|
||||
|
||||
private static void ModifyCode(string _path)
|
||||
{
|
||||
#if !AppStore_GB
|
||||
ToukaClassHelper SplashScreenController = new ToukaClassHelper(_path + "/Classes/UI/SplashScreen.mm");
|
||||
|
||||
if (!SplashScreenController.HasBolow("#import <TKGUNITYSDK/TONativeSplashHelper.h>"))
|
||||
ToukaClassHelper SplashScreenControllers = new ToukaClassHelper(_path + "/Classes/UI/SplashScreen.mm");
|
||||
if (!SplashScreenControllers.HasBolow("#import <SJMajorSDK/TKGSplashAd.h>"))
|
||||
{
|
||||
|
||||
SplashScreenController.WriteBelow("#include \"SplashScreen.h\"", "#import <TKGUNITYSDK/TONativeSplashHelper.h>");
|
||||
SplashScreenController.WriteBelow("void HideSplashScreen()\n{", "[[TONativeSplashHelper helper]showSplashInLaunch];");
|
||||
|
||||
SplashScreenControllers.WriteBelow("#include \"SplashScreen.h\"", "#import <SJMajorSDK/TKGSplashAd.h>");
|
||||
SplashScreenControllers.WriteBelow("void HideSplashScreen()\n{", "[TKGSplashAd showSplashAdInLaunch];");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
ToukaClassHelper UnityAppController = new ToukaClassHelper(_path + "/Classes/UnityAppController.mm");
|
||||
if (!UnityAppController.HasBolow("[TKGSplashAd showsplashAdInEnterForground];"))
|
||||
{
|
||||
UnityAppController.WriteBelow("#import \"UnityAppController.h\"", "\n#import <SJMajorSDK/TKGSplashAd.h>");
|
||||
UnityAppController.WriteBelow("UnityPause(0);", "\n[TKGSplashAd showsplashAdInEnterForground];");
|
||||
}
|
||||
|
||||
// 友盟调试
|
||||
if (!UnityAppController.HasBolow("return [TKGSplashAd showUMDebugModel:url];"))
|
||||
{
|
||||
UnityAppController.WriteBelow("AppController_SendNotificationWithArg(kUnityOnOpenURL, notifData);", "\nreturn [TKGSplashAd showUMDebugModel:url];");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,15 +16,18 @@ public class ToukaAnalyticsBuildPostProcessor
|
|||
if (buildTarget != BuildTarget.iOS) return;
|
||||
|
||||
#if UNITY_IOS
|
||||
|
||||
#if AppStore_GB || AppStore_CN
|
||||
|
||||
copyConfigFile(path);
|
||||
CopySplashImg(path);
|
||||
#endif
|
||||
|
||||
SetTeamIdAutoSign(path);
|
||||
ModifyFrameworks(path);
|
||||
ModifyBuildSettings(path);
|
||||
|
||||
ModifyInfoPlist(path);
|
||||
|
||||
//AddLocalization(path);
|
||||
CopySplashImg(path);
|
||||
ModifyUnitySettings(path);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -61,7 +64,7 @@ public class ToukaAnalyticsBuildPostProcessor
|
|||
proj.AddFrameworkToProject(target, "SafariServices.framework", false);
|
||||
proj.AddFrameworkToProject(target, "VideoToolbox.framework", false);
|
||||
proj.AddFrameworkToProject(target, "WebKit.framework", false);
|
||||
|
||||
proj.AddFrameworkToProject(target, "DeviceCheck.framework", false);
|
||||
|
||||
|
||||
string fileGuidSqlite = proj.AddFile("usr/lib/libxml2.tbd", "Libraries/libxml2.tbd", PBXSourceTree.Sdk);
|
||||
|
|
@ -81,9 +84,7 @@ public class ToukaAnalyticsBuildPostProcessor
|
|||
fileGuidSqlite = proj.AddFile("usr/lib/libc++abi.tbd", "Libraries/libc++abi.tbd", PBXSourceTree.Sdk);
|
||||
proj.AddFileToBuild(target, fileGuidSqlite);
|
||||
|
||||
// sdk config files
|
||||
proj.AddFileToBuild(target, proj.AddFile("tkg_config.plist", "tkg_config.plist",PBXSourceTree.Source));
|
||||
File.WriteAllText(projPath, proj.WriteToString());
|
||||
|
||||
|
||||
#if UNITY_2019_3_OR_NEWER
|
||||
string mainTarget = proj.GetUnityMainTargetGuid();
|
||||
|
|
@ -91,6 +92,12 @@ public class ToukaAnalyticsBuildPostProcessor
|
|||
string targetName = UnityEditor.iOS.Xcode.PBXProject.GetUnityTargetName();
|
||||
string mainTarget = proj.TargetGuidByName(targetName);
|
||||
#endif
|
||||
|
||||
#if AppStore_GB || AppStore_CN
|
||||
// sdk config files
|
||||
proj.AddFileToBuild(target, proj.AddFile("tkg_config.plist", "tkg_config.plist",PBXSourceTree.Source));
|
||||
File.WriteAllText(projPath, proj.WriteToString());
|
||||
|
||||
proj.AddFileToBuild(mainTarget, proj.AddFile("tkg_config.plist", "tkg_config.plist", PBXSourceTree.Source));
|
||||
proj.WriteToFile(projPath);
|
||||
|
||||
|
|
@ -108,7 +115,7 @@ public class ToukaAnalyticsBuildPostProcessor
|
|||
proj.WriteToFile(projPath);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -132,6 +139,18 @@ public class ToukaAnalyticsBuildPostProcessor
|
|||
#endif
|
||||
}
|
||||
|
||||
private static void ModifyUnitySettings(string _path)
|
||||
{
|
||||
#if UNITY_IOS
|
||||
string projPath = PBXProject.GetPBXProjectPath(_path);
|
||||
PBXProject proj = new PBXProject();
|
||||
proj.ReadFromString(File.ReadAllText(projPath));
|
||||
string target = proj.GetUnityMainTargetGuid();
|
||||
proj.SetBuildProperty(target, "ENABLE_BITCODE", "NO");
|
||||
File.WriteAllText(projPath, proj.WriteToString());
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
private static void ModifyBuildSettings(string _path)
|
||||
{
|
||||
|
|
@ -150,9 +169,8 @@ public class ToukaAnalyticsBuildPostProcessor
|
|||
proj.SetBuildProperty(target, "ENABLE_BITCODE", "NO");
|
||||
proj.SetBuildProperty(target, "GCC_C_LANGUAGE_STANDARD", "gnu99");
|
||||
proj.SetBuildProperty(target, "GCC_ENABLE_OBJC_EXCEPTIONS","YES");
|
||||
proj.SetBuildProperty(target, "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES", "NO");
|
||||
proj.SetBuildProperty(target, "EXCLUDED_ARCHS", "EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64=arm64 arm64e armv7 armv7s armv6 armv8 EXCLUDED_ARCHS=$(inherited) $(EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_$(EFFECTIVE_PLATFORM_SUFFIX)__NATIVE_ARCH_64_BIT_$(NATIVE_ARCH_64_BIT))");
|
||||
|
||||
|
||||
File.WriteAllText(projPath, proj.WriteToString());
|
||||
#endif
|
||||
}
|
||||
|
|
@ -174,14 +192,18 @@ public class ToukaAnalyticsBuildPostProcessor
|
|||
var plistPath = Path.Combine(_path, "Info.plist");
|
||||
var plist = new PlistDocument();
|
||||
plist.ReadFromFile(plistPath);
|
||||
#if !AppStore_GB
|
||||
#if AppStore_CN
|
||||
plist.root.SetString("NSLocationAlwaysUsageDescription", "为了更好的体验游戏");
|
||||
plist.root.SetString("NSCameraUsageDescription", "为了更好的体验游戏");
|
||||
plist.root.SetString("NSLocationWhenInUseUsageDescription", "为了更好的体验游戏");
|
||||
plist.root.SetString("NSUserTrackingUsageDescription", "该标识符将用于向您投放个性化广告");
|
||||
plist.root.SetString("NSPhotoLibraryUsageDescription", "为了更好的体验游戏,请允许APP保存图片到您的相册");
|
||||
plist.root.SetString("NSCalendarsUsageDescription", "为了更好的体验游戏");
|
||||
|
||||
|
||||
|
||||
#else
|
||||
plist.root.SetString("NSCalendarsUsageDescription", "for better experience the game");
|
||||
plist.root.SetString ("NSLocationAlwaysUsageDescription", "for better experience the game");
|
||||
plist.root.SetString("NSCameraUsageDescription", "for better experience the game");
|
||||
plist.root.SetString ("NSLocationWhenInUseUsageDescription", "for better experience the game");
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ namespace Touka
|
|||
[MenuItem("ToukaGames/Settings For IOS CN", priority=1001)]
|
||||
public static void SetIOSCNTOPONSeting()
|
||||
{
|
||||
#if UNITY_IOS
|
||||
#if UNITY_IOS && AppStore_CN
|
||||
SetAPPSetting(AppChannel.AppStore_CN);
|
||||
#endif
|
||||
}
|
||||
|
|
@ -42,7 +42,7 @@ namespace Touka
|
|||
[MenuItem("ToukaGames/Settings For IOS GB", priority = 10001)]
|
||||
public static void SetIOSUSSeting()
|
||||
{
|
||||
#if UNITY_IOS
|
||||
#if UNITY_IOS && AppStore_GB
|
||||
SetAPPSetting(AppChannel.AppStore_GB);
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,111 @@
|
|||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Touka
|
||||
{
|
||||
public class ToukaSDKManagerEditor : EditorWindow
|
||||
{
|
||||
private static bool useGuestLogin = true;
|
||||
private static bool useFbLogin;
|
||||
private static bool useGoogleLogin;
|
||||
private static string fbUserId = "fb_123";
|
||||
private static string googleUserId = "google_123";
|
||||
|
||||
[MenuItem("ToukaGames/Open GM Panel", priority = 20000)]
|
||||
static void OpenPanel()
|
||||
{
|
||||
var loginChannels = PlayerPrefs.GetString("loginChannels", "" + (int)LoginType.LOGIN_BY_GUESTER);
|
||||
|
||||
foreach (var c in loginChannels.Split(','))
|
||||
{
|
||||
var channel = int.Parse(c);
|
||||
switch (channel)
|
||||
{
|
||||
case (int)LoginType.LOGIN_BY_GUESTER:
|
||||
useGuestLogin = true;
|
||||
break;
|
||||
case (int)LoginType.LOGIN_BY_FACEBOOK:
|
||||
useFbLogin = true;
|
||||
break;
|
||||
case (int)LoginType.LOGIN_BY_GOOGLE:
|
||||
useGoogleLogin = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
googleUserId = PlayerPrefs.GetString("google_user_id", "google_123");
|
||||
fbUserId = PlayerPrefs.GetString("facebook_user_id", "fb_123");
|
||||
|
||||
|
||||
var window = (ToukaSDKManagerEditor)GetWindow(typeof(ToukaSDKManagerEditor));
|
||||
window.Show();
|
||||
}
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
GUILayout.Label("Login Options", EditorStyles.boldLabel);
|
||||
|
||||
EditorGUI.BeginDisabledGroup(true);
|
||||
useGuestLogin = EditorGUILayout.Toggle("Guest Login", useGuestLogin);
|
||||
EditorGUI.EndDisabledGroup();
|
||||
useFbLogin = EditorGUILayout.Toggle("Facebook Login", useFbLogin);
|
||||
|
||||
if (useFbLogin)
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
fbUserId = EditorGUILayout.TextField("Facebook UserID", fbUserId);
|
||||
if (GUILayout.Button("Default"))
|
||||
{
|
||||
fbUserId = "fb_123";
|
||||
}
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
useGoogleLogin = EditorGUILayout.Toggle("Google Login", useGoogleLogin);
|
||||
|
||||
if (useGoogleLogin)
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
googleUserId = EditorGUILayout.TextField("Google UserID", googleUserId);
|
||||
if (GUILayout.Button("Default"))
|
||||
{
|
||||
googleUserId = "google_123";
|
||||
}
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Save"))
|
||||
{
|
||||
// Save the login options
|
||||
SaveLoginOptions();
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveLoginOptions()
|
||||
{
|
||||
var loginChannels = "";
|
||||
if (useGuestLogin)
|
||||
{
|
||||
loginChannels += (int)LoginType.LOGIN_BY_GUESTER;
|
||||
}
|
||||
|
||||
if (useFbLogin)
|
||||
{
|
||||
loginChannels += "," + (int)LoginType.LOGIN_BY_FACEBOOK;
|
||||
PlayerPrefs.SetString("facebook_user_id", fbUserId);
|
||||
}
|
||||
|
||||
if (useGoogleLogin)
|
||||
{
|
||||
loginChannels += "," + (int)LoginType.LOGIN_BY_GOOGLE;
|
||||
PlayerPrefs.SetString("google_user_id", googleUserId);
|
||||
}
|
||||
|
||||
PlayerPrefs.SetString("loginChannels", loginChannels);
|
||||
|
||||
EditorUtility.DisplayDialog("保存成功", "你的更改已成功保存!重启游戏后生效。", "确定");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6cee47f3d8e84410be0d0429f7e5d393
|
||||
timeCreated: 1690681962
|
||||
|
|
@ -11,7 +11,7 @@ namespace Touka
|
|||
{
|
||||
private static TKGNativeInterface _instance;
|
||||
|
||||
private string UnitySDKVersion = "2.2.6";
|
||||
private string UnitySDKVersion = "3.1.3";
|
||||
|
||||
public static TKGNativeInterface Instance
|
||||
{
|
||||
|
|
@ -335,6 +335,28 @@ namespace Touka
|
|||
/// </summary>
|
||||
public abstract void OpenMoreGame();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// if is debug mode
|
||||
/// </summary>
|
||||
public abstract bool IsDebugMode();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// get user name and user id card
|
||||
/// </summary>
|
||||
public abstract string GetUserNameAndUserIDCard();
|
||||
|
||||
/// <summary>
|
||||
/// set segment type to sdk
|
||||
/// </summary>
|
||||
/// <param name="type">segment type</param>
|
||||
public abstract void SetSegment(SegmentType type);
|
||||
|
||||
/// <summary>
|
||||
/// get a iap product list for sdk config file
|
||||
/// </summary>
|
||||
public abstract Dictionary<string, string> GetIAPProductList();
|
||||
#endregion
|
||||
|
||||
#region Others (Uncommon)
|
||||
|
|
@ -407,6 +429,26 @@ namespace Touka
|
|||
/// </summary>
|
||||
public abstract void RegistAPNS();
|
||||
|
||||
/// <summary>
|
||||
/// show picture cross
|
||||
/// </summary>
|
||||
public abstract bool showPictureCross();
|
||||
|
||||
/// <summary>
|
||||
/// remove picture cross
|
||||
/// </summary>
|
||||
public abstract void removePictureCross();
|
||||
|
||||
/// <summary>
|
||||
/// show more game icon
|
||||
/// </summary>
|
||||
public abstract bool showMoreGameIcon();
|
||||
|
||||
/// <summary>
|
||||
/// remove more game icon
|
||||
/// </summary>
|
||||
public abstract void removeMoreGameIcon();
|
||||
|
||||
/// <summary>
|
||||
/// shake
|
||||
/// </summary>
|
||||
|
|
@ -447,6 +489,131 @@ namespace Touka
|
|||
/// </summary>
|
||||
public abstract void SetUserSourceCallback(AndroidTKGUserSourceCalllbackWithCampaignName _userSourceCallback);
|
||||
|
||||
/// <summary>
|
||||
/// Set Function Switch Calllback
|
||||
/// </summary>
|
||||
public abstract void SetFunctionSwitchCalllback(List<FunctionType> _functionKeys ,AndroidFunctionSwitchCalllback _functionSwitchCalllback);
|
||||
|
||||
#endregion
|
||||
|
||||
#region 数据中台
|
||||
|
||||
public abstract void LogPurchasePrice(string price,string currency);
|
||||
|
||||
public abstract void LogRobuxCashOut();
|
||||
|
||||
public abstract void LogNoviceGuideFinish();
|
||||
|
||||
#endregion
|
||||
|
||||
#region GooglePlay评论引导
|
||||
/// <summary>
|
||||
/// Pop up GooglePlay Rate guid
|
||||
/// </summary>
|
||||
public abstract bool GuidGpComment();
|
||||
#endregion
|
||||
|
||||
|
||||
#region 用户登录
|
||||
/// <summary>
|
||||
/// User Login
|
||||
/// </summary>
|
||||
public abstract void Login(LoginType loginType, Action<LoginStatus, LoginType, string, string, string, string,string,string> _loginResultCallback = null);
|
||||
/// <summary>
|
||||
/// Logout
|
||||
/// </summary>
|
||||
public abstract void Logout(Action _logoutCallback = null);
|
||||
|
||||
public abstract List<LoginType> AvailableLoginChannelList();
|
||||
|
||||
public abstract void DeleteAccount(Action<DeleteStatus,string> _deleteAccountCallback = null);
|
||||
|
||||
public abstract void BindAccount(LoginType type,BindType isForce, string userId,
|
||||
Action<BindAccountStatus, LoginType, string, string, string, string, string, string, string[]>
|
||||
bindAccountCallback);
|
||||
|
||||
public abstract void AutoLogin(
|
||||
Action<LoginStatus, LoginType, string, string, string, string, string, string> loginResultCallback);
|
||||
|
||||
public abstract LoginType GetAccountType();
|
||||
|
||||
public abstract bool IsCanAutoLogin();
|
||||
|
||||
#endregion
|
||||
|
||||
#region IAP Event
|
||||
|
||||
/// <summary>
|
||||
/// Log IAP button show
|
||||
/// </summary>
|
||||
/// <param name="_productName">Product name (customized on the game side) English name of the product cannot contain special characters ex: Gem100</param>
|
||||
/// <param name="_productID">Product ID: The ID of a specific product type</param>
|
||||
public abstract void LogIAPBtnShow(string _productName, string _productID);
|
||||
|
||||
/// <summary>
|
||||
/// Log IAP button Click
|
||||
/// </summary>
|
||||
/// <param name="_productName">Product name (customized on the game side) English name of the product cannot contain special characters ex: Gem100</param>
|
||||
/// <param name="_productID">Product ID: The ID of a specific product type</param>
|
||||
public abstract void LogIAPBtnClick(string _productName, string _productID);
|
||||
|
||||
/// <summary>
|
||||
/// Log IAP First payment successful
|
||||
/// </summary>
|
||||
/// <param name="_iap">Product name (customized on the game side) English name of the product cannot contain special characters ex: Gem100</param>
|
||||
/// <param name="_id">Product ID: The ID of a specific product type</param>
|
||||
/// <param name="_paymentChannelOrderid">The order id returned by the payment channel</param>
|
||||
/// <param name="_currency">Currency ex:USD</param>
|
||||
/// <param name="_price">Price</param>
|
||||
public abstract void LogIAPFirstPurchase(string _iap, string _id, string _paymentChannelOrderid, string _currency, string _price);
|
||||
|
||||
/// <summary>
|
||||
/// Log IAP payment successful
|
||||
/// </summary>
|
||||
/// <param name="_iap">Product name (customized on the game side) English name of the product cannot contain special characters ex: Gem100</param>
|
||||
/// <param name="_id">Product ID: The ID of a specific product type</param>
|
||||
/// <param name="_gameOrderid">The order id on the game side</param>
|
||||
/// <param name="_paymentChannelOrderid">The order id returned by the payment channel</param>
|
||||
/// <param name="_productToken">Purchase token: When the purchase is successful on GP, a purchase token will be generated as a unique identifier</param>
|
||||
/// <param name="_paymentMethod">Official payment channels: appstore, googleplay, other payment channels corresponding channel name</param>
|
||||
/// <param name="_currency">Currency ex:USD</param>
|
||||
/// <param name="_price">Price</param>
|
||||
public abstract void LogIAPSuccess(string _iap, string _id, string _gameOrderid, string _paymentChannelOrderid, string _productToken, string _paymentMethod, string _currency, string _price);
|
||||
|
||||
#endregion
|
||||
|
||||
#region MyRegion
|
||||
|
||||
public abstract void SaveCloudArchiving(string content, Action<int, string> callback);
|
||||
|
||||
public abstract void DetailCloudArchiving(Action<int, string> callback);
|
||||
|
||||
#endregion
|
||||
|
||||
#region serve for wz
|
||||
|
||||
/// <summary>
|
||||
/// Set userid and third account
|
||||
/// </summary>
|
||||
/// <param name="_userID"> userID (Unique user id)</param>
|
||||
/// <param name="_thirdAccount">third account </param>
|
||||
/// <param name="_thirdAccountType"> third account type </param>
|
||||
public abstract void SetUserIDAndThirdAccount(string _userID, string _thirdAccount, ThirdAccountType _thirdAccountType);
|
||||
|
||||
#endregion
|
||||
|
||||
#region client iap pay result
|
||||
/// <summary>
|
||||
/// Client IAP Success
|
||||
/// </summary>
|
||||
public abstract void ClientIAPSuccess(string _productName, string _productID, string _purchaseOrderID, string _purchaseToken, string _currency, string _price, string _gameExtra);
|
||||
|
||||
/// <summary>
|
||||
/// Client IAP Failed
|
||||
/// </summary>
|
||||
public abstract void ClientIAPFailed(string _productName, string _productID, string _purchaseOrderID, string _purchaseToken, string _currency, string _price, string _gameExtra, IAPClientFailReasonType _failType);
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Touka
|
||||
|
|
@ -12,7 +13,6 @@ namespace Touka
|
|||
/// </summary>
|
||||
public class TKGNativeInterfaceAndroid : TKGNativeInterface
|
||||
{
|
||||
|
||||
private AndroidJavaObject jo;
|
||||
|
||||
public TKGNativeInterfaceAndroid()
|
||||
|
|
@ -34,6 +34,7 @@ namespace Touka
|
|||
{
|
||||
Debug.LogError(e);
|
||||
}
|
||||
|
||||
return default(T);
|
||||
}
|
||||
|
||||
|
|
@ -49,7 +50,7 @@ namespace Touka
|
|||
}
|
||||
}
|
||||
|
||||
#region init
|
||||
#region init
|
||||
|
||||
/// <summary>
|
||||
/// init
|
||||
|
|
@ -68,12 +69,24 @@ namespace Touka
|
|||
TKGDebugger.LogDebug("init ----- 01 ------- c");
|
||||
SetSDKCommonCallback(new AndroidTKGCommonCalllback());
|
||||
TKGDebugger.LogDebug("init ----- 01 ------- d");
|
||||
|
||||
SetSecondPurchaseCallback();
|
||||
SetAdsRevenueCallback();
|
||||
SDKCall("init", new AndroidProxyCallback());
|
||||
TKGDebugger.LogDebug("init ----- 02");
|
||||
}
|
||||
|
||||
#endregion
|
||||
private void SetSecondPurchaseCallback()
|
||||
{
|
||||
#if USE_IAP
|
||||
SDKCall("setSecondPurchaseCallback", new SecondPurchaseCallback());
|
||||
#endif
|
||||
}
|
||||
private void SetAdsRevenueCallback()
|
||||
{
|
||||
SDKCall("setAdsRevenueCallback", new AdsRevenueCallback());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Get Channel
|
||||
|
|
@ -87,7 +100,7 @@ namespace Touka
|
|||
return "AndroidRoot";
|
||||
}
|
||||
|
||||
#region Ads
|
||||
#region Ads
|
||||
|
||||
public override void PurchasedRemoveAds()
|
||||
{
|
||||
|
|
@ -98,14 +111,12 @@ namespace Touka
|
|||
|
||||
public override void SetUnitySDKVersion(string sdkVersion)
|
||||
{
|
||||
|
||||
#if UNITY_ANDROID
|
||||
SDKCall("setUnitySDKVersion","UnitySDK",sdkVersion);
|
||||
SDKCall("setUnitySDKVersion", "UnitySDK", sdkVersion);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#region Ads Show
|
||||
#region Ads Show
|
||||
|
||||
/// <summary>
|
||||
/// Show banner Ad
|
||||
|
|
@ -114,12 +125,11 @@ namespace Touka
|
|||
public override void showBannerAd(TKGBannerAlign _pos)
|
||||
{
|
||||
int _posIndex = 2;
|
||||
if(_pos == TKGBannerAlign.BannerCenterTopAlign)
|
||||
if (_pos == TKGBannerAlign.BannerCenterTopAlign)
|
||||
{
|
||||
_posIndex = 1;
|
||||
|
||||
}
|
||||
else if(_pos == TKGBannerAlign.BannerCenterBottomAlign)
|
||||
else if (_pos == TKGBannerAlign.BannerCenterBottomAlign)
|
||||
{
|
||||
_posIndex = 2;
|
||||
}
|
||||
|
|
@ -161,7 +171,6 @@ namespace Touka
|
|||
/// <param name="_adPos"></param>
|
||||
public override void showInterstitialAd(string _adPos, IVADType _IvType = IVADType.IV1)
|
||||
{
|
||||
|
||||
#if UNITY_ANDROID
|
||||
SDKCall("showInterstitialAd", _adPos, (int)_IvType);
|
||||
#endif
|
||||
|
|
@ -174,7 +183,6 @@ namespace Touka
|
|||
/// <param name="_itemCount"></param>
|
||||
public override void showRewardAd(string _adPos, int _itemCount = -1)
|
||||
{
|
||||
|
||||
#if UNITY_ANDROID
|
||||
SDKCall("showRewardAd", _adPos, _itemCount);
|
||||
#endif
|
||||
|
|
@ -208,8 +216,8 @@ namespace Touka
|
|||
public override void SetShowSDKToast(bool _useSDKToast)
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
SDKCall("setShowSDKRewardTips", _useSDKToast);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
public override void ShowNativeAd(RectTransform pRect, Camera pCam = null, string pAdPos = "")
|
||||
|
|
@ -224,14 +232,14 @@ namespace Touka
|
|||
float tHeight = Mathf.Abs(tBottomRight.y - tTopLeft.y);
|
||||
// x , y , width , height
|
||||
// ((tTopLeft.x, Screen.height - tTopLeft.y, tWidth, tHeight)
|
||||
SDKCall("showNative", pAdPos, tTopLeft.x, Screen.height - tTopLeft.y, tWidth, tHeight, pAdPos);
|
||||
SDKCall("showNative", pAdPos, tTopLeft.x, Screen.height - tTopLeft.y, tWidth, tHeight);
|
||||
#endif
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Ads isready
|
||||
#region Ads isready
|
||||
|
||||
/// <summary>
|
||||
/// banner isReady
|
||||
|
|
@ -239,7 +247,6 @@ namespace Touka
|
|||
/// <returns></returns>
|
||||
public override bool isBannerAdReady()
|
||||
{
|
||||
|
||||
#if UNITY_ANDROID
|
||||
bool isReady = SDKCall<bool>("isBannerAdReady");
|
||||
return isReady;
|
||||
|
|
@ -268,7 +275,6 @@ namespace Touka
|
|||
/// <returns></returns>
|
||||
public override bool isRewardAdReady()
|
||||
{
|
||||
|
||||
#if UNITY_ANDROID
|
||||
bool isReady = SDKCall<bool>("isRewardAdReady");
|
||||
return isReady;
|
||||
|
|
@ -301,9 +307,9 @@ namespace Touka
|
|||
#endif
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Set ads callback
|
||||
#region Set ads callback
|
||||
|
||||
/// <summary>
|
||||
/// Set Banner Ad Callback
|
||||
|
|
@ -345,15 +351,14 @@ namespace Touka
|
|||
/// <param name="_videoCallback"></param>
|
||||
public override void setVideoAdCallback(AndroidInterADTKGAdCallback _videoCallback)
|
||||
{
|
||||
|
||||
#if UNITY_ANDROID
|
||||
SDKCall("setVideoAdCallback", _videoCallback);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region load ads
|
||||
#region load ads
|
||||
|
||||
/// <summary>
|
||||
/// load interstitial ad
|
||||
|
|
@ -388,14 +393,14 @@ namespace Touka
|
|||
#endif
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
|
||||
#region Log Event
|
||||
#region Log Event
|
||||
|
||||
#region Normal
|
||||
#region Normal
|
||||
|
||||
/// <summary>
|
||||
/// onEvent
|
||||
|
|
@ -451,9 +456,9 @@ namespace Touka
|
|||
#endif
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Level Event
|
||||
#region Level Event
|
||||
|
||||
/// <summary>
|
||||
/// Level Start
|
||||
|
|
@ -478,9 +483,9 @@ namespace Touka
|
|||
#endif
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Tracking Event
|
||||
#region Tracking Event
|
||||
|
||||
/// <summary>
|
||||
/// Log Tracking Event
|
||||
|
|
@ -493,11 +498,11 @@ namespace Touka
|
|||
#endif
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region Online Config
|
||||
#region Online Config
|
||||
|
||||
/// <summary>
|
||||
/// get config - int
|
||||
|
|
@ -535,10 +540,9 @@ namespace Touka
|
|||
return newValue;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Others (Common)
|
||||
#region Others (Common)
|
||||
|
||||
/// <summary>
|
||||
/// review
|
||||
|
|
@ -588,9 +592,42 @@ namespace Touka
|
|||
{
|
||||
SDKCall("setEnableLog", _enable);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Others (Uncommon)
|
||||
/// <summary>
|
||||
/// get a iap product list for sdk config file
|
||||
/// </summary>
|
||||
public override Dictionary<string, string> GetIAPProductList()
|
||||
{
|
||||
Dictionary<string, string> dic = new Dictionary<string, string>();
|
||||
return dic;
|
||||
}
|
||||
|
||||
public override bool IsDebugMode()
|
||||
{
|
||||
return SDKCall<bool>("isDebugMode");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// get user name and user id card
|
||||
/// </summary>
|
||||
public override string GetUserNameAndUserIDCard()
|
||||
{
|
||||
return "0_0";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// set segment type to sdk
|
||||
/// </summary>
|
||||
/// <param name="type">segment type</param>
|
||||
public override void SetSegment(SegmentType type)
|
||||
{
|
||||
SDKCall("setSegment", type.ToString());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Others (Uncommon)
|
||||
|
||||
/// <summary>
|
||||
/// shake(no repeat)
|
||||
|
|
@ -657,7 +694,7 @@ namespace Touka
|
|||
/// <param name="_content"></param>
|
||||
public override void toast(string _content)
|
||||
{
|
||||
SDKCall("toast");
|
||||
SDKCall("dialogTips", _content);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -679,27 +716,79 @@ namespace Touka
|
|||
|
||||
public override void RegistAPNS()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void RegistNotification(string notiId, string body, string fireDate, int badge, string title, string subTitle)
|
||||
/// <summary>
|
||||
/// show picture cross
|
||||
/// </summary>
|
||||
public override bool showPictureCross()
|
||||
{
|
||||
return SDKCall<bool>("showPictureCross");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// remove picture cross
|
||||
/// </summary>
|
||||
public override void removePictureCross()
|
||||
{
|
||||
SDKCall("removePictureCross");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// show more game icon
|
||||
/// </summary>
|
||||
public override bool showMoreGameIcon()
|
||||
{
|
||||
return SDKCall<bool>("showMoreGameIcon");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// remove more game icon
|
||||
/// </summary>
|
||||
public override void removeMoreGameIcon()
|
||||
{
|
||||
SDKCall("removeMoreGameIcon");
|
||||
}
|
||||
|
||||
|
||||
public override void RegistNotification(string notiId, string body, string fireDate, int badge, string title,
|
||||
string subTitle)
|
||||
{
|
||||
SDKCall("registNotification", notiId, body, fireDate, badge, title, subTitle);
|
||||
}
|
||||
|
||||
public override void RemoveNotification(string notiId)
|
||||
{
|
||||
|
||||
SDKCall("removeNotification", notiId);
|
||||
}
|
||||
|
||||
public override void RemoveAllNotifications()
|
||||
{
|
||||
|
||||
SDKCall("removeAllNotifications");
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region common callback
|
||||
#region 数据中台
|
||||
|
||||
public override void LogPurchasePrice(string price, string currency)
|
||||
{
|
||||
SDKCall("logPurchasePrice", price, currency);
|
||||
}
|
||||
|
||||
public override void LogRobuxCashOut()
|
||||
{
|
||||
SDKCall("logRobuxCashOut");
|
||||
}
|
||||
|
||||
public override void LogNoviceGuideFinish()
|
||||
{
|
||||
SDKCall("logNoviceGuideFinish");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region common callback
|
||||
|
||||
public override void SetSDKCommonCallback(AndroidTKGCommonCalllback _commonCallback)
|
||||
{
|
||||
|
|
@ -717,8 +806,227 @@ namespace Touka
|
|||
SDKCall("getUserSource", _userSourceCallback);
|
||||
}
|
||||
|
||||
#endregion
|
||||
public override void SetFunctionSwitchCalllback(List<FunctionType> _functionKeys,
|
||||
AndroidFunctionSwitchCalllback _functionSwitchCalllback)
|
||||
{
|
||||
string keys = "";
|
||||
|
||||
for (int i = 0; i < _functionKeys.Count; i++)
|
||||
{
|
||||
FunctionType enumType = _functionKeys[i];
|
||||
string enumTypeString = enumType.ToString();
|
||||
if (keys != "")
|
||||
{
|
||||
keys = keys + "@";
|
||||
}
|
||||
|
||||
keys = keys + enumTypeString;
|
||||
}
|
||||
|
||||
SDKCall("setGameSwitchListener", keys, _functionSwitchCalllback);
|
||||
}
|
||||
|
||||
public override bool GuidGpComment()
|
||||
{
|
||||
return SDKCall<bool>("guidGpComment");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 用户登录
|
||||
|
||||
public override void Login(LoginType loginType,
|
||||
Action<LoginStatus, LoginType, string, string, string, string, string, string> _loginResultCallback = null)
|
||||
{
|
||||
TKGSDKCallback.mLoginCallback = _loginResultCallback;
|
||||
SDKCall("login", (int)loginType, new AndroidLoginCalllback());
|
||||
}
|
||||
|
||||
public override void Logout(Action _logoutCallback = null)
|
||||
{
|
||||
TKGSDKCallback.mLogoutCallback = _logoutCallback;
|
||||
SDKCall("logout", new AndroidLoginCalllback());
|
||||
}
|
||||
|
||||
public override List<LoginType> AvailableLoginChannelList()
|
||||
{
|
||||
var availableLoginChannelList = SDKCall<int[]>("availableLoginChannelList");
|
||||
return availableLoginChannelList.Select(channel => (LoginType)Enum.ToObject(typeof(LoginType), channel))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public override void DeleteAccount(Action<DeleteStatus, string> deleteAccountCallback = null)
|
||||
{
|
||||
TKGSDKCallback.mDeleteAccountCallback = deleteAccountCallback;
|
||||
SDKCall("deleteAccount", new AndroidLoginCalllback());
|
||||
}
|
||||
|
||||
public override void BindAccount(LoginType type, BindType isForce, string userId,
|
||||
Action<BindAccountStatus, LoginType, string, string, string, string, string, string, string[]>
|
||||
bindAccountCallback)
|
||||
{
|
||||
TKGSDKCallback.mBindAccountCallback = bindAccountCallback;
|
||||
SDKCall("bindAccount", (int)type, (int)isForce, userId, new AndroidLoginCalllback());
|
||||
}
|
||||
|
||||
public override void AutoLogin(
|
||||
Action<LoginStatus, LoginType, string, string, string, string, string, string> loginResultCallback)
|
||||
{
|
||||
TKGSDKCallback.mAutoLoginCallback = loginResultCallback;
|
||||
SDKCall("autoLogin", new AndroidLoginCalllback(isAutoLogin: true));
|
||||
}
|
||||
|
||||
public override LoginType GetAccountType()
|
||||
{
|
||||
var userType = SDKCall<int>("getUserType");
|
||||
return (LoginType)Enum.ToObject(typeof(LoginType), userType);
|
||||
}
|
||||
|
||||
public override bool IsCanAutoLogin()
|
||||
{
|
||||
return SDKCall<bool>("isCanAutoLogin");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IAP Event
|
||||
|
||||
/// <summary>
|
||||
/// Log IAP button show
|
||||
/// </summary>
|
||||
public override void LogIAPBtnShow(string _productName, string _productID)
|
||||
{
|
||||
Dictionary<string, string> _keyValues = new Dictionary<string, string>();
|
||||
_keyValues.Add("IAP", _productName);
|
||||
_keyValues.Add("ID", _productID);
|
||||
//_keyValues.Add("Currency", _currency);
|
||||
//_keyValues.Add("Price", _price);
|
||||
onEvent("IAP_Button_Show", _keyValues);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Log IAP button Click
|
||||
/// </summary>
|
||||
public override void LogIAPBtnClick(string _productName, string _productID)
|
||||
{
|
||||
Dictionary<string, string> _keyValues = new Dictionary<string, string>();
|
||||
_keyValues.Add("IAP", _productName);
|
||||
_keyValues.Add("ID", _productID);
|
||||
//_keyValues.Add("Currency", _currency);
|
||||
//_keyValues.Add("Price", _price);
|
||||
onEvent("IAP_Button_Click", _keyValues);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Log IAP First payment successful
|
||||
/// </summary>
|
||||
public override void LogIAPFirstPurchase(string _iap, string _id, string _paymentChannelOrderid,
|
||||
string _currency, string _price)
|
||||
{
|
||||
// 放到native层实现了
|
||||
//Dictionary<string, string> _keyValues = new Dictionary<string, string>();
|
||||
//_keyValues.Add("IAP", _iap);
|
||||
//_keyValues.Add("ID", _id);
|
||||
//_keyValues.Add("Currency", _currency);
|
||||
//_keyValues.Add("Price", _price);
|
||||
//_keyValues.Add("order_id", _paymentChannelOrderid);
|
||||
//onEvent("First_purchase", _keyValues);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Log IAP payment successful
|
||||
/// </summary>
|
||||
public override void LogIAPSuccess(string _iap, string _id, string _gameOrderid, string _paymentChannelOrderid,
|
||||
string _productToken, string _paymentMethod, string _currency, string _price)
|
||||
{
|
||||
// 放到native层实现了
|
||||
//Dictionary<string, string> _keyValues = new Dictionary<string, string>();
|
||||
//_keyValues.Add("IAP", _iap);
|
||||
//_keyValues.Add("ID", _id);
|
||||
//_keyValues.Add("Currency", _currency);
|
||||
//_keyValues.Add("Price", _price);
|
||||
//_keyValues.Add("order_id", _paymentChannelOrderid);
|
||||
//onEvent("IAP_Success", _keyValues);
|
||||
//SDKCall("logIAPSuccess", _price, _id, _gameOrderid, _paymentChannelOrderid, _productToken, _currency, _paymentMethod, _iap);
|
||||
}
|
||||
|
||||
public override void SaveCloudArchiving(string content, Action<int, string> callback)
|
||||
{
|
||||
void Action(CommonCallbackCode code, string s)
|
||||
{
|
||||
if (code == CommonCallbackCode.SaveCloudArchiving_Succ ||
|
||||
code == CommonCallbackCode.SaveCloudArchiving_Fail)
|
||||
{
|
||||
callback.Invoke(code == CommonCallbackCode.SaveCloudArchiving_Succ ? 0 : -1, s);
|
||||
TKGSDKCallback.RemoveTKGCommonCallback(Action);
|
||||
}
|
||||
}
|
||||
|
||||
TKGSDKCallback.SetTKGCommonCallback(Action);
|
||||
SDKCall("saveCloudArchiving", content);
|
||||
}
|
||||
|
||||
public override void DetailCloudArchiving(Action<int, string> callback)
|
||||
{
|
||||
void Action(CommonCallbackCode code, string s)
|
||||
{
|
||||
if (code == CommonCallbackCode.DetailCloudArchiving_Succ ||
|
||||
code == CommonCallbackCode.DetailCloudArchiving_Fail)
|
||||
{
|
||||
callback.Invoke(code == CommonCallbackCode.DetailCloudArchiving_Succ ? 0 : -1, s);
|
||||
TKGSDKCallback.RemoveTKGCommonCallback(Action);
|
||||
}
|
||||
}
|
||||
|
||||
TKGSDKCallback.SetTKGCommonCallback(Action);
|
||||
SDKCall("detailCloudArchiving");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region serve for wz
|
||||
|
||||
/// <summary>
|
||||
/// Set userid and third account
|
||||
/// </summary>
|
||||
/// <param name="_userID"> userID (Unique user id)</param>
|
||||
/// <param name="_thirdAccount">third account </param>
|
||||
/// <param name="_thirdAccountType"> third account type </param>
|
||||
public override void SetUserIDAndThirdAccount(string _userID, string _thirdAccount,
|
||||
ThirdAccountType _thirdAccountType)
|
||||
{
|
||||
Debug.Log("【TKGNativeInterfaceAndroid】 SetUserIDAndThirdAccount _userID : " + _userID +
|
||||
" , _thirdAccount : " + _thirdAccount + " , _thirdAccountType : " + _thirdAccountType);
|
||||
SDKCall("setUserIDAndThirdAccount", _userID, _thirdAccount, _thirdAccountType.ToString());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region client iap pay result
|
||||
|
||||
/// <summary>
|
||||
/// Client IAP Success
|
||||
/// </summary>
|
||||
public override void ClientIAPSuccess(string _productName, string _productID, string _purchaseOrderID,
|
||||
string _purchaseToken, string _currency, string _price, string _gameExtra)
|
||||
{
|
||||
SDKCall("ClientIAPSuccess", _productName, _productID, _purchaseOrderID, _purchaseToken, _currency, _price,
|
||||
_gameExtra);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Client IAP Failed
|
||||
/// </summary>
|
||||
public override void ClientIAPFailed(string _productName, string _productID, string _purchaseOrderID,
|
||||
string _purchaseToken, string _currency, string _price, string _gameExtra,
|
||||
IAPClientFailReasonType _failType)
|
||||
{
|
||||
SDKCall("ClientIAPFailed", _productName, _productID, _purchaseOrderID, _purchaseToken, _currency, _price,
|
||||
_gameExtra, _failType.ToString());
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Touka
|
||||
|
|
@ -17,7 +18,6 @@ namespace Touka
|
|||
|
||||
public override void SetUnitySDKVersion(string sdkVersion)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -35,14 +35,12 @@ namespace Touka
|
|||
/// <param name="_enable"></param>
|
||||
public override void SetLogEnable(bool _enable)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#region Ads
|
||||
|
||||
public override void PurchasedRemoveAds()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#region Ads Show
|
||||
|
|
@ -53,7 +51,6 @@ namespace Touka
|
|||
/// <param name="_bannerAlign">bannerAlign</param>
|
||||
public override void showBannerAd(TKGBannerAlign _pos)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -61,7 +58,6 @@ namespace Touka
|
|||
/// </summary>
|
||||
public override void hideBannerAd()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -69,7 +65,6 @@ namespace Touka
|
|||
/// </summary>
|
||||
public override void showInterstitialAd()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -77,7 +72,6 @@ namespace Touka
|
|||
/// </summary>
|
||||
public override void showInterstitialAd(string _adPos, IVADType _IvType = IVADType.IV1)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -85,7 +79,6 @@ namespace Touka
|
|||
/// </summary>
|
||||
public override void showRewardAd(string _adPos, int _itemCount = -1)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -96,7 +89,6 @@ namespace Touka
|
|||
/// <param name="_extraEvent"></param>
|
||||
public override void showRewardAd(string _adPos, int _itemCount, Dictionary<string, string> _extraEvent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -104,7 +96,6 @@ namespace Touka
|
|||
/// </summary>
|
||||
public override void showVideoAd(string _adPos, int _itemCount = -1)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
@ -158,7 +149,6 @@ namespace Touka
|
|||
/// <param name="_bannerCallback"></param>
|
||||
public override void SetBannerAdCallback(AndroidBannerADTKGAdCallback _bannerCallback)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -167,7 +157,6 @@ namespace Touka
|
|||
/// <param name="_rewardClickAction"></param>
|
||||
public override void SetRewardClickListener(Action _rewardClickAction)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -176,7 +165,6 @@ namespace Touka
|
|||
/// <param name=""></param>
|
||||
public override void SetGameFocusListener(Action<bool> _gameFocusAction)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -185,7 +173,6 @@ namespace Touka
|
|||
/// <param name="_interCallback"></param>
|
||||
public override void setInterstitalAdCallback(AndroidInterADTKGAdCallback _interCallback)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -194,7 +181,6 @@ namespace Touka
|
|||
/// <param name="_rewardCallback"></param>
|
||||
public override void SetRewardAdCallback(AndroidRewardADTKGAdCallback _rewardCallback)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -203,7 +189,6 @@ namespace Touka
|
|||
/// <param name="_videoCallback"></param>
|
||||
public override void setVideoAdCallback(AndroidInterADTKGAdCallback _videoCallback)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
@ -216,7 +201,6 @@ namespace Touka
|
|||
/// </summary>
|
||||
public override void loadInterstitialAD()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -225,7 +209,6 @@ namespace Touka
|
|||
/// </summary>
|
||||
public override void loadRewardAD()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -234,10 +217,8 @@ namespace Touka
|
|||
/// </summary>
|
||||
public override void loadVideoAD()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
|
@ -252,7 +233,6 @@ namespace Touka
|
|||
/// <returns></returns>
|
||||
public override void onEvent(string _eventName)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -264,7 +244,6 @@ namespace Touka
|
|||
/// <returns></returns>
|
||||
public override void onEvent(string _eventName, string _key01, string _value01)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -278,7 +257,6 @@ namespace Touka
|
|||
/// <returns></returns>
|
||||
public override void onEvent(string _eventName, string _key01, string _value01, string _key02, string _value02)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -288,7 +266,6 @@ namespace Touka
|
|||
/// <param name="_keyValues"></param>
|
||||
public override void onEvent(string _eventName, Dictionary<string, string> _keyValues)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#region Level Event
|
||||
|
|
@ -299,7 +276,6 @@ namespace Touka
|
|||
/// <param name="_levelId"></param>
|
||||
public override void LevelStart(string _levelId)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -309,7 +285,6 @@ namespace Touka
|
|||
/// <param name="_stageResult"></param>
|
||||
public override void LevelEnd(string _levelId, StageResult _stageResult)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
@ -322,12 +297,10 @@ namespace Touka
|
|||
/// <param name="_eventType"></param>
|
||||
public override void LogTrackingEvent(TrackingEventType _eventType)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Online Config
|
||||
|
|
@ -371,7 +344,6 @@ namespace Touka
|
|||
/// </summary>
|
||||
public override void Review()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -379,7 +351,6 @@ namespace Touka
|
|||
/// </summary>
|
||||
public override void OpenPrivacyURL()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -387,7 +358,6 @@ namespace Touka
|
|||
/// </summary>
|
||||
public override void OpenUserTermURL()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -395,7 +365,6 @@ namespace Touka
|
|||
/// </summary>
|
||||
public override void OpenPolicyPop()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -403,7 +372,6 @@ namespace Touka
|
|||
/// </summary>
|
||||
public override void OpenMoreGame()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
@ -416,7 +384,36 @@ namespace Touka
|
|||
/// <param name="_shakeTime"> shake time </param>
|
||||
public override void shake(int _shakeType, float _intensity = 1)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// show picture cross
|
||||
/// </summary>
|
||||
public override bool showPictureCross()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// remove picture cross
|
||||
/// </summary>
|
||||
public override void removePictureCross()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// show more game icon
|
||||
/// </summary>
|
||||
public override bool showMoreGameIcon()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// remove more game icon
|
||||
/// </summary>
|
||||
public override void removeMoreGameIcon()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -434,7 +431,6 @@ namespace Touka
|
|||
/// </summary>
|
||||
public override void cancelShake()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -447,7 +443,6 @@ namespace Touka
|
|||
/// <param name="_contentStr"> content </param>
|
||||
public override void dialogTips(string _titleStr, string _contentStr)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -456,7 +451,6 @@ namespace Touka
|
|||
/// <param name="_url"></param>
|
||||
public override void openUrlBrowser(string _url)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -465,7 +459,6 @@ namespace Touka
|
|||
/// <param name="_url"></param>
|
||||
public override void openWebUrl(string _url)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -474,7 +467,6 @@ namespace Touka
|
|||
/// <param name="_content"></param>
|
||||
public override void toast(string _content)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -482,7 +474,6 @@ namespace Touka
|
|||
/// </summary>
|
||||
public override void pushMsg()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
@ -491,23 +482,50 @@ namespace Touka
|
|||
|
||||
public override void SetSDKCommonCallback(AndroidTKGCommonCalllback _commonCallback)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void SetUserSourceCallback(AndroidTKGUserSourceCalllback _userSourceCallback)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void SetUserSourceCallback(AndroidTKGUserSourceCalllbackWithCampaignName _userSourceCallback)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get a iap product list for sdk config file
|
||||
/// </summary>
|
||||
public override Dictionary<string, string> GetIAPProductList()
|
||||
{
|
||||
return new Dictionary<string, string>();
|
||||
}
|
||||
|
||||
public override void RemoveNativeAd()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// set segment type to sdk
|
||||
/// </summary>
|
||||
/// <param name="type">segment type</param>
|
||||
public override void SetSegment(SegmentType type)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool IsDebugMode()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get user name and user id card
|
||||
/// </summary>
|
||||
public override string GetUserNameAndUserIDCard()
|
||||
{
|
||||
return "0_0";
|
||||
}
|
||||
|
||||
public override bool IsReadyNativeAd()
|
||||
{
|
||||
return false;
|
||||
|
|
@ -515,41 +533,265 @@ namespace Touka
|
|||
|
||||
public override void ShowNativeAd(RectTransform pRect, Camera pCam = null, string pAdPos = "")
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void ShareTxt(string _shareTxt)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
public override void RegistAPNS()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void RegistNotification(string notiId, string body, string fireDate, int badge, string title, string subTitle)
|
||||
public override void RegistNotification(string notiId, string body, string fireDate, int badge, string title,
|
||||
string subTitle)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void RemoveNotification(string notiId)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void RemoveAllNotifications()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void SetShowSDKToast(bool _useSDKToast)
|
||||
{
|
||||
}
|
||||
|
||||
public override void SetFunctionSwitchCalllback(List<FunctionType> _functionKeys,
|
||||
AndroidFunctionSwitchCalllback _functionSwitchCalllback)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 数据中台
|
||||
|
||||
public override void LogPurchasePrice(string price,string currency)
|
||||
{
|
||||
}
|
||||
|
||||
public override void LogRobuxCashOut()
|
||||
{
|
||||
}
|
||||
|
||||
public override void LogNoviceGuideFinish()
|
||||
{
|
||||
}
|
||||
|
||||
public override bool GuidGpComment()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 用户登录
|
||||
|
||||
public override void Login(LoginType loginType,
|
||||
Action<LoginStatus, LoginType, string, string, string, string, string, string> loginResultCallback = null)
|
||||
{
|
||||
Server.Instance.Login(loginType, (status, msg, loginInfo) =>
|
||||
{
|
||||
PlayerPrefs.SetInt("last_login_type", (int)loginType);
|
||||
var loginStatus = status == 0 ? LoginStatus.LOGIN_STATUS_SUCC : LoginStatus.LOGIN_STATUS_FAILED;
|
||||
var loginTypeEnum = (LoginType)Enum.ToObject(typeof(LoginType), loginInfo.user_type);
|
||||
PlayerPrefs.SetString("user_id", loginInfo.user_id);
|
||||
PlayerPrefs.SetString("token", loginInfo.token);
|
||||
PlayerPrefs.SetInt("user_type", loginInfo.user_type);
|
||||
loginResultCallback?.Invoke(loginStatus, loginTypeEnum, msg, loginInfo.user_id, loginInfo.token, "", "",
|
||||
"");
|
||||
});
|
||||
}
|
||||
|
||||
public override void Logout(Action _logoutCallback = null)
|
||||
{
|
||||
PlayerPrefs.DeleteKey("last_login_type");
|
||||
PlayerPrefs.DeleteKey("user_id");
|
||||
PlayerPrefs.DeleteKey("user_type");
|
||||
PlayerPrefs.DeleteKey("token");
|
||||
_logoutCallback?.Invoke();
|
||||
}
|
||||
|
||||
public override List<LoginType> AvailableLoginChannelList()
|
||||
{
|
||||
var loginChannels = PlayerPrefs.GetString("loginChannels", "" + (int)LoginType.LOGIN_BY_GUESTER);
|
||||
return loginChannels.Split(',')
|
||||
.Select(channel => (LoginType)Enum.ToObject(typeof(LoginType), int.Parse(channel))).ToList();
|
||||
}
|
||||
|
||||
public override void DeleteAccount(Action<DeleteStatus, string> deleteAccountCallback = null)
|
||||
{
|
||||
Server.Instance.DeleteAccount(PlayerPrefs.GetString("user_id"), (code, msg) =>
|
||||
{
|
||||
// 退出账号
|
||||
Logout();
|
||||
deleteAccountCallback?.Invoke(
|
||||
code == 0 ? DeleteStatus.DELETE_ACCOUNT_SUCC : DeleteStatus.DELETE_ACCOUNT_FAILED, msg);
|
||||
});
|
||||
}
|
||||
|
||||
public override void BindAccount(LoginType type, BindType isForce, string userId,
|
||||
Action<BindAccountStatus, LoginType, string, string, string, string, string, string, string[]>
|
||||
bindAccountCallback)
|
||||
{
|
||||
var thirdUserId = "";
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case LoginType.LOGIN_BY_GOOGLE:
|
||||
thirdUserId = PlayerPrefs.GetString("google_user_id");
|
||||
break;
|
||||
case LoginType.LOGIN_BY_FACEBOOK:
|
||||
thirdUserId = PlayerPrefs.GetString("facebook_user_id");
|
||||
break;
|
||||
}
|
||||
|
||||
if (isForce == BindType.NO_FORCE)
|
||||
{
|
||||
userId = PlayerPrefs.GetString("user_id");
|
||||
}
|
||||
|
||||
Server.Instance.Bind(type, isForce, thirdUserId, userId, (status, msg, data) =>
|
||||
{
|
||||
if (status != 0)
|
||||
{
|
||||
bindAccountCallback.Invoke(BindAccountStatus.BIND_CODE_FAILED, type, msg, data.user_id, data.token,
|
||||
"", "", "", data.user_ids);
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.user_ids != null && data.user_ids.Length == 2)
|
||||
{
|
||||
// (status, loginTYpe, msg, userId, token, email, displayName, photoUrl, userIdList)
|
||||
bindAccountCallback.Invoke(BindAccountStatus.BIND_CODE_SELECT, type, msg, data.user_id, data.token,
|
||||
"", "", "", data.user_ids);
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerPrefs.SetString("user_id", data.user_id);
|
||||
PlayerPrefs.SetString("token", data.token);
|
||||
PlayerPrefs.SetInt("user_type", (int)type);
|
||||
|
||||
bindAccountCallback.Invoke(BindAccountStatus.BIND_CODE_SUCC, type, msg, data.user_id, data.token,
|
||||
"", "", "", data.user_ids);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public override void AutoLogin(
|
||||
Action<LoginStatus, LoginType, string, string, string, string, string, string> loginResultCallback)
|
||||
{
|
||||
if (!IsCanAutoLogin())
|
||||
{
|
||||
loginResultCallback?.Invoke(LoginStatus.LOGIN_STATUS_NO_CACHE, LoginType.LOGIN_BY_AUTO,
|
||||
"not cache login", "", "", "", "", "");
|
||||
}
|
||||
else
|
||||
{
|
||||
var lastLoginType = PlayerPrefs.GetInt("last_login_type");
|
||||
Login((LoginType)Enum.ToObject(typeof(LoginType), lastLoginType), loginResultCallback);
|
||||
}
|
||||
}
|
||||
|
||||
public override LoginType GetAccountType()
|
||||
{
|
||||
var userType = PlayerPrefs.GetInt("user_type");
|
||||
return (LoginType)Enum.ToObject(typeof(LoginType), userType);
|
||||
}
|
||||
|
||||
public override bool IsCanAutoLogin()
|
||||
{
|
||||
return PlayerPrefs.HasKey("last_login_type");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IAP Event
|
||||
|
||||
/// <summary>
|
||||
/// Log IAP button show
|
||||
/// </summary>
|
||||
public override void LogIAPBtnShow(string _productName, string _productID)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Log IAP button Click
|
||||
/// </summary>
|
||||
public override void LogIAPBtnClick(string _productName, string _productID)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Log IAP First payment successful
|
||||
/// </summary>
|
||||
public override void LogIAPFirstPurchase(string _iap, string _id, string _paymentChannelOrderid, string _currency, string _price)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Log IAP payment successful
|
||||
/// </summary>
|
||||
public override void LogIAPSuccess(string _iap, string _id, string _gameOrderid, string _paymentChannelOrderid,
|
||||
string _productToken, string _paymentMethod, string _currency, string _price)
|
||||
{
|
||||
}
|
||||
|
||||
public override void SaveCloudArchiving(string content, Action<int, string> callback)
|
||||
{
|
||||
var userId = PlayerPrefs.GetString("user_id");
|
||||
var token = PlayerPrefs.GetString("token");
|
||||
Server.Instance.SaveCloudArchiving(userId, token, content, callback);
|
||||
}
|
||||
|
||||
public override void DetailCloudArchiving(Action<int, string> callback)
|
||||
{
|
||||
var userId = PlayerPrefs.GetString("user_id");
|
||||
var token = PlayerPrefs.GetString("token");
|
||||
Server.Instance.DetailCloudArchiving(userId, token,
|
||||
(code, msg, content) => { callback.Invoke(code, code == 0 ? content : msg); });
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region
|
||||
|
||||
/// <summary>
|
||||
/// Set userid and third account
|
||||
/// </summary>
|
||||
/// <param name="_userID"> userID (Unique user id)</param>
|
||||
/// <param name="_thirdAccount">third account </param>
|
||||
/// <param name="_thirdAccountType"> third account type </param>
|
||||
public override void SetUserIDAndThirdAccount(string _userID, string _thirdAccount, ThirdAccountType _thirdAccountType)
|
||||
{
|
||||
Debug.Log("【TKGNativeInterfaceDefault】 SetUserIDAndThirdAccount _userID : " + _userID + " , _thirdAccount : " + _thirdAccount + " , _thirdAccountType : " + _thirdAccountType);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region client iap pay result
|
||||
/// <summary>
|
||||
/// Client IAP Success
|
||||
/// </summary>
|
||||
public override void ClientIAPSuccess(string _productName, string _productID, string _purchaseOrderID, string _purchaseToken, string _currency, string _price, string _gameExtra)
|
||||
{
|
||||
// todo 直接回调支付成功
|
||||
TKGSDKCallback.mSecondPurchaseCallback?.Invoke(_purchaseOrderID,_productName, _productID, true, _gameExtra);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Client IAP Failed
|
||||
/// </summary>
|
||||
public override void ClientIAPFailed(string _productName, string _productID, string _purchaseOrderID, string _purchaseToken, string _currency, string _price, string _gameExtra, IAPClientFailReasonType _failType)
|
||||
{
|
||||
// todo 直接回调支付失败
|
||||
TKGSDKCallback.mSecondPurchaseCallback?.Invoke(_purchaseOrderID, _productName, _productID, false, _gameExtra);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -26,11 +26,7 @@ namespace Touka
|
|||
/// <returns></returns>
|
||||
public override string GetChannel()
|
||||
{
|
||||
#if !AppStore_GB
|
||||
return "AppStore_CN";
|
||||
#else
|
||||
return "AppStore_GB";
|
||||
#endif
|
||||
return TGiOSAdManager.Instance.getChannel().ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -61,6 +57,7 @@ namespace Touka
|
|||
}
|
||||
|
||||
|
||||
|
||||
public override void RemoveNativeAd()
|
||||
{
|
||||
#if !UNITY_EDITOR
|
||||
|
|
@ -511,6 +508,55 @@ namespace Touka
|
|||
TGiOSAdManager.Instance.share(_shareTxt);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// show picture cross
|
||||
/// </summary>
|
||||
public override bool showPictureCross()
|
||||
{
|
||||
|
||||
#if UNITY_EDITOR
|
||||
return false;
|
||||
#else
|
||||
return TGiOSAdManager.Instance.showPictureCross();
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// remove picture cross
|
||||
/// </summary>
|
||||
public override void removePictureCross()
|
||||
{
|
||||
|
||||
#if !UNITY_EDITOR
|
||||
TGiOSAdManager.Instance.removePictureCross();
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// show more game icon
|
||||
/// </summary>
|
||||
public override bool showMoreGameIcon()
|
||||
{
|
||||
|
||||
#if UNITY_EDITOR
|
||||
return false;
|
||||
#else
|
||||
return TGiOSAdManager.Instance.showMoreGameIcon();
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// remove more game icon
|
||||
/// </summary>
|
||||
public override void removeMoreGameIcon()
|
||||
{
|
||||
|
||||
#if !UNITY_EDITOR
|
||||
TGiOSAdManager.Instance.removeMoreGameIcon();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
public override void RegistAPNS()
|
||||
{
|
||||
#if !UNITY_EDITOR
|
||||
|
|
@ -551,6 +597,35 @@ namespace Touka
|
|||
TGiOSAdManager.Instance.shake(_shakeType,_intensity);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get a iap product list for sdk config file
|
||||
/// </summary>
|
||||
public override Dictionary<string, string> GetIAPProductList()
|
||||
{
|
||||
return TGiOSAdManager.Instance.getIAPProductList() ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// set segment type to sdk
|
||||
/// </summary>
|
||||
/// <param name="type">segment type</param>
|
||||
public override void SetSegment(SegmentType type)
|
||||
{
|
||||
TGiOSAdManager.Instance.SetSegment(type.ToString());
|
||||
}
|
||||
|
||||
public override bool IsDebugMode()
|
||||
{
|
||||
return TGiOSAdManager.Instance.isDebugMode();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get user name and user id card
|
||||
/// </summary>
|
||||
public override string GetUserNameAndUserIDCard()
|
||||
{
|
||||
return TGiOSAdManager.Instance.getUserNameAndUserIDCard();
|
||||
}
|
||||
/// <summary>
|
||||
/// shake(can repeat)
|
||||
/// </summary>
|
||||
|
|
@ -621,6 +696,32 @@ namespace Touka
|
|||
|
||||
#endregion
|
||||
|
||||
#region 数据中台
|
||||
|
||||
public override void LogPurchasePrice(string price,string currency)
|
||||
{
|
||||
|
||||
#if !UNITY_EDITOR
|
||||
TGiOSAdManager.Instance.LogPurchasePrice(price,currency);
|
||||
#endif
|
||||
}
|
||||
|
||||
public override void LogRobuxCashOut()
|
||||
{
|
||||
#if !UNITY_EDITOR
|
||||
TGiOSAdManager.Instance.LogRobuxCashOut();
|
||||
#endif
|
||||
}
|
||||
|
||||
public override void LogNoviceGuideFinish()
|
||||
{
|
||||
#if !UNITY_EDITOR
|
||||
TGiOSAdManager.Instance.LogNoviceGuideFinish();
|
||||
#endif
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region common callback
|
||||
|
||||
public override void SetSDKCommonCallback(AndroidTKGCommonCalllback _commonCallback)
|
||||
|
|
@ -638,10 +739,227 @@ namespace Touka
|
|||
|
||||
}
|
||||
|
||||
public override void SetFunctionSwitchCalllback(List<FunctionType> _functionKeys, AndroidFunctionSwitchCalllback _functionSwitchCalllback)
|
||||
{
|
||||
|
||||
string temp = "";
|
||||
if (_functionKeys.Count != 0)
|
||||
{
|
||||
for (int index = 0; index < _functionKeys.Count; index++)
|
||||
{
|
||||
|
||||
if (index == _functionKeys.Count - 1)
|
||||
{
|
||||
temp += _functionKeys[index];
|
||||
}
|
||||
else
|
||||
{
|
||||
temp = temp + _functionKeys[index] + ",";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TGiOSAdManager.Instance.setFunctions(temp);
|
||||
}
|
||||
|
||||
public override bool GuidGpComment()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 用户登录
|
||||
public override void Login(LoginType loginType, Action<LoginStatus, LoginType, string, string, string, string,string,string> _loginResultCallback = null)
|
||||
{
|
||||
TKGSDKCallback.mLoginCallback = _loginResultCallback;
|
||||
TKGiOSLoginManager.Instance.Login(loginType);
|
||||
}
|
||||
|
||||
public override void Logout(Action _logoutCallback = null)
|
||||
{
|
||||
TKGSDKCallback.mLogoutCallback = _logoutCallback;
|
||||
TKGiOSLoginManager.Instance.Logout();
|
||||
}
|
||||
|
||||
public override List<LoginType> AvailableLoginChannelList()
|
||||
{
|
||||
return TKGiOSLoginManager.Instance.AvailableLoginChannelList();
|
||||
}
|
||||
|
||||
public override void DeleteAccount(Action<DeleteStatus,string> _deleteAccountCallback = null)
|
||||
{
|
||||
TKGSDKCallback.mDeleteAccountCallback = _deleteAccountCallback;
|
||||
TKGiOSLoginManager.Instance.DeleteAccount();
|
||||
}
|
||||
|
||||
public override void BindAccount(LoginType type, BindType isForce, string userId, Action<BindAccountStatus, LoginType, string, string, string, string, string, string, string[]> bindAccountCallback)
|
||||
{
|
||||
TKGSDKCallback.mBindAccountCallback = bindAccountCallback;
|
||||
TKGiOSLoginManager.Instance.BindAccount(type,isForce,userId);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IAP Event
|
||||
|
||||
/// <summary>
|
||||
/// Log IAP button show
|
||||
/// </summary>
|
||||
/// <param name="_productName">Product name (customized on the game side) English name of the product cannot contain special characters ex: Gem100</param>
|
||||
/// <param name="_productID">Product ID: The ID of a specific product type</param>
|
||||
/// <param name="_currency">Currency ex:USD</param>
|
||||
/// <param name="_price">Price</param>
|
||||
public override void LogIAPBtnShow(string _productName, string _productID)
|
||||
{
|
||||
Dictionary<string, string> _keyValues = new Dictionary<string, string>();
|
||||
_keyValues.Add("IAP", _productName);
|
||||
_keyValues.Add("ID", _productID);
|
||||
//_keyValues.Add("Currency", _currency);
|
||||
//_keyValues.Add("Price", _price);
|
||||
onEvent("IAP_Button_Show", _keyValues);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Log IAP button Click
|
||||
/// </summary>
|
||||
/// <param name="_productName">Product name (customized on the game side) English name of the product cannot contain special characters ex: Gem100</param>
|
||||
/// <param name="_productID">Product ID: The ID of a specific product type</param>
|
||||
/// <param name="_currency">Currency ex:USD</param>
|
||||
/// <param name="_price">Price</param>
|
||||
public override void LogIAPBtnClick(string _productName, string _productID)
|
||||
{
|
||||
Dictionary<string, string> _keyValues = new Dictionary<string, string>();
|
||||
_keyValues.Add("IAP", _productName);
|
||||
_keyValues.Add("ID", _productID);
|
||||
//_keyValues.Add("Currency", _currency);
|
||||
//_keyValues.Add("Price", _price);
|
||||
onEvent("IAP_Button_Click", _keyValues);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Log IAP First payment successful
|
||||
/// </summary>
|
||||
/// <param name="_iap">Product name (customized on the game side) English name of the product cannot contain special characters ex: Gem100</param>
|
||||
/// <param name="_id">Product ID: The ID of a specific product type</param>
|
||||
/// <param name="_currency">Currency ex:USD</param>
|
||||
/// <param name="_price">Price</param>
|
||||
public override void LogIAPFirstPurchase(string _iap, string _id, string _paymentChannelOrderid, string _currency, string _price)
|
||||
{
|
||||
// native 层实现
|
||||
//Dictionary<string, string> _keyValues = new Dictionary<string, string>();
|
||||
//_keyValues.Add("IAP", _iap);
|
||||
//_keyValues.Add("ID", _id);
|
||||
//_keyValues.Add("Currency", _currency);
|
||||
//_keyValues.Add("Price", _price);
|
||||
//_keyValues.Add("order_id", _paymentChannelOrderid);
|
||||
//onEvent("First_purchase", _keyValues);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Log IAP payment successful
|
||||
/// </summary>
|
||||
/// <param name="_iap">Product name (customized on the game side) English name of the product cannot contain special characters ex: Gem100</param>
|
||||
/// <param name="_id">Product ID: The ID of a specific product type</param>
|
||||
/// <param name="_gameOrderid">The order id on the game side</param>
|
||||
/// <param name="_paymentChannelOrderid">The order id returned by the payment channel</param>
|
||||
/// <param name="_productToken">Purchase token: When the purchase is successful on GP, a purchase token will be generated as a unique identifier</param>
|
||||
/// <param name="_paymentMethod">Official payment channels: appstore, googleplay, other payment channels corresponding channel name</param>
|
||||
/// <param name="_currency">Currency ex:USD</param>
|
||||
/// <param name="_price">Price</param>
|
||||
public override void LogIAPSuccess(string _iap, string _id, string _gameOrderid, string _paymentChannelOrderid, string _productToken, string _paymentMethod, string _currency, string _price)
|
||||
{
|
||||
//Dictionary<string, string> _keyValues = new Dictionary<string, string>();
|
||||
//_keyValues.Add("IAP", _iap);
|
||||
//_keyValues.Add("ID", _id);
|
||||
//_keyValues.Add("Currency", _currency);
|
||||
//_keyValues.Add("Price", _price);
|
||||
//_keyValues.Add("order_id", _paymentChannelOrderid);
|
||||
//onEvent("IAP_Success", _keyValues);
|
||||
|
||||
//Dictionary<string, string> _dataCenterDict = new Dictionary<string, string>();
|
||||
//_dataCenterDict.Add("iap_name", _iap);
|
||||
//_dataCenterDict.Add("product_id",_id);
|
||||
//_dataCenterDict.Add("game_order_id",_gameOrderid);
|
||||
//_dataCenterDict.Add("order_id",_paymentChannelOrderid);
|
||||
//_dataCenterDict.Add("purchase_token", _productToken);
|
||||
//_dataCenterDict.Add("payment_method", _paymentMethod);
|
||||
//_dataCenterDict.Add("currency", _currency);
|
||||
//_dataCenterDict.Add("price", _price);
|
||||
//onEvent("IAP_DataCenter",_dataCenterDict);
|
||||
|
||||
}
|
||||
|
||||
public override void AutoLogin(Action<LoginStatus, LoginType, string, string, string, string, string, string> loginResultCallback)
|
||||
{
|
||||
TKGSDKCallback.mLoginCallback = loginResultCallback;
|
||||
TKGiOSLoginManager.Instance.AutoLogin();
|
||||
}
|
||||
|
||||
public override LoginType GetAccountType()
|
||||
{
|
||||
var userType = PlayerPrefs.GetInt("user_type");
|
||||
return (LoginType)Enum.ToObject(typeof(LoginType), userType);
|
||||
}
|
||||
|
||||
public override void SaveCloudArchiving(string content, Action<int, string> callback)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void DetailCloudArchiving(Action<int, string> callback)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override bool IsCanAutoLogin()
|
||||
{
|
||||
|
||||
return TKGiOSLoginManager.Instance.IsCanAutoLogin();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region serve for wz
|
||||
|
||||
/// <summary>
|
||||
/// Set userid and third account
|
||||
/// </summary>
|
||||
/// <param name="_userID"> userID (Unique user id)</param>
|
||||
/// <param name="_thirdAccount">third account </param>
|
||||
/// <param name="_thirdAccountType"> third account type </param>
|
||||
public override void SetUserIDAndThirdAccount(string _userID, string _thirdAccount, ThirdAccountType _thirdAccountType)
|
||||
{
|
||||
Debug.Log("【TKGNativeInterfaceiOS】 SetUserIDAndThirdAccount _userID : " + _userID + " , _thirdAccount : " + _thirdAccount + " , _thirdAccountType : " + _thirdAccountType);
|
||||
#if !UNITY_EDITOR
|
||||
TGiOSAdManager.Instance.setUserIDAndThirdAccount(_userID, _thirdAccount, _thirdAccountType);
|
||||
#endif
|
||||
}
|
||||
#endregion
|
||||
#region client iap pay result
|
||||
/// <summary>
|
||||
/// Client IAP Success
|
||||
/// </summary>
|
||||
public override void ClientIAPSuccess(string _productName, string _productID, string _purchaseOrderID, string _purchaseToken, string _currency, string _price, string _gameExtra)
|
||||
{
|
||||
#if !UNITY_EDITOR
|
||||
TGiOSAdManager.Instance.IAP_ClientIAPSuccess(_productName, _productID, _purchaseOrderID, _purchaseToken, _currency, _price, _gameExtra);
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Client IAP Failed
|
||||
/// </summary>
|
||||
public override void ClientIAPFailed(string _productName, string _productID, string _purchaseOrderID, string _purchaseToken, string _currency, string _price, string _gameExtra, IAPClientFailReasonType _failType)
|
||||
{
|
||||
#if !UNITY_EDITOR
|
||||
TGiOSAdManager.Instance.IAP_ClientIAPFailed(_productName, _productID, _purchaseOrderID, _purchaseToken, _currency, _price, _gameExtra, _failType);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,12 +21,31 @@ namespace Touka
|
|||
// tkg user source
|
||||
public static Action<bool, string, string> mTKGUserSourceCallbackWithCampaignName = null;
|
||||
|
||||
//FunctionSwitchCalllback
|
||||
public static Action<FunctionType, bool> mFunctionSwitchCalllback = null;
|
||||
|
||||
// tkg common callback
|
||||
public static Action<CommonCallbackCode, string> mTKGCommonCallback = null;
|
||||
|
||||
// tkg reward click callback
|
||||
public static Action mRewardClickCallback = null;
|
||||
|
||||
// tkg ads revenue callback
|
||||
// adsType, price, currency
|
||||
public static Action<AdsType, string, string> mAdsRevenueCallback = null;
|
||||
|
||||
// Login result callback
|
||||
public static Action<LoginStatus,LoginType, string, string, string,string,string,string> mLoginCallback = null;
|
||||
|
||||
// Logout callback
|
||||
public static Action mLogoutCallback = null;
|
||||
|
||||
public static Action<DeleteStatus,string> mDeleteAccountCallback = null;
|
||||
|
||||
public static Action<BindAccountStatus,LoginType,string,string,string,string,string,string,string[]> mBindAccountCallback;
|
||||
|
||||
// auto Login result callback
|
||||
public static Action<LoginStatus,LoginType, string, string, string,string,string,string> mAutoLoginCallback = null;
|
||||
|
||||
#region 插屏广告
|
||||
|
||||
|
|
@ -52,6 +71,16 @@ namespace Touka
|
|||
|
||||
#endregion
|
||||
|
||||
#region iap
|
||||
|
||||
/// <summary>
|
||||
/// SecondPurchaseCallback
|
||||
/// orderID, productName, productID, purchase result, game extra param
|
||||
/// </summary>
|
||||
public static Action<string,string,string, bool, string> mSecondPurchaseCallback = null;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// set init callback
|
||||
|
|
@ -77,7 +106,16 @@ namespace Touka
|
|||
/// <param name="_commonCallbackAction"></param>
|
||||
public static void SetTKGCommonCallback(Action<CommonCallbackCode, string> _commonCallbackAction)
|
||||
{
|
||||
mTKGCommonCallback = _commonCallbackAction;
|
||||
mTKGCommonCallback += _commonCallbackAction;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// set common callback
|
||||
/// </summary>
|
||||
/// <param name="_commonCallbackAction"></param>
|
||||
public static void RemoveTKGCommonCallback(Action<CommonCallbackCode, string> _commonCallbackAction)
|
||||
{
|
||||
mTKGCommonCallback -= _commonCallbackAction;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -99,9 +137,52 @@ namespace Touka
|
|||
mTKGUserSourceCallbackWithCampaignName = _userSourceCallbackWithCampaignNameAction;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Set Function Switch Calllback
|
||||
/// </summary>
|
||||
/// <param name="_userSourceCallbackAction"></param>
|
||||
public static void SetFunctionSwitchCalllback(Action<FunctionType, bool> _functionSwitchCalllback)
|
||||
{
|
||||
mFunctionSwitchCalllback = _functionSwitchCalllback;
|
||||
}
|
||||
|
||||
#region for wz
|
||||
|
||||
/// <summary>
|
||||
/// Set Reward Click Callback
|
||||
/// </summary>
|
||||
/// <param name="_rewardClickAction"></param>
|
||||
public static void SetRewardClickCallback(Action _rewardClickAction)
|
||||
{
|
||||
mRewardClickCallback = _rewardClickAction;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// ads revenue callback
|
||||
/// </summary>
|
||||
/// adsType, price, currency
|
||||
/// <param name="_adsRevenueCallback"></param>
|
||||
public static void SetAdsRevenueCallback(Action<AdsType, string, string> _adsRevenueCallback)
|
||||
{
|
||||
mAdsRevenueCallback = _adsRevenueCallback;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IAP Second purchase
|
||||
|
||||
/// <summary>
|
||||
/// set game pause/resume callback
|
||||
/// orderID, productName, productID, purchase result, game extra param
|
||||
/// </summary>
|
||||
/// <param name="_gameFocusAction"></param>
|
||||
public static void SetSecondPurchaseCallback(Action<string,string,string, bool, string> _nativePurchaseAction)
|
||||
{
|
||||
mSecondPurchaseCallback = _nativePurchaseAction;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
|
|
@ -6,17 +7,17 @@ namespace Touka
|
|||
{
|
||||
public class TKGSDKCallbackAndroid
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// TGK framework level callback
|
||||
/// </summary>
|
||||
public class AndroidProxyCallback : AndroidJavaProxy
|
||||
{
|
||||
public AndroidProxyCallback() : base("com.touka.tkg.idal.ITKGProxyCallback") { }
|
||||
public AndroidProxyCallback() : base("com.touka.tkg.idal.ITKGProxyCallback")
|
||||
{
|
||||
}
|
||||
|
||||
// init succ callback
|
||||
public void onInitSuccess()
|
||||
|
|
@ -87,7 +88,6 @@ namespace Touka
|
|||
{
|
||||
TKGSDKCallback.mGameFocusCallback.Invoke(false);
|
||||
}
|
||||
|
||||
}, "");
|
||||
}
|
||||
|
||||
|
|
@ -104,7 +104,6 @@ namespace Touka
|
|||
}
|
||||
}, "");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -112,7 +111,9 @@ namespace Touka
|
|||
/// </summary>
|
||||
public class AndroidInterADTKGAdCallback : AndroidJavaProxy
|
||||
{
|
||||
public AndroidInterADTKGAdCallback() : base("com.touka.tkg.idal.ITKGAdCallback") { }
|
||||
public AndroidInterADTKGAdCallback() : base("com.touka.tkg.idal.ITKGAdCallback")
|
||||
{
|
||||
}
|
||||
|
||||
public void onClosed()
|
||||
{
|
||||
|
|
@ -125,8 +126,8 @@ namespace Touka
|
|||
TKGSDKCallback.mInterAdCallback = null;
|
||||
}
|
||||
}, "");
|
||||
|
||||
}
|
||||
|
||||
public void onClicked()
|
||||
{
|
||||
TKGDebugger.LogDebug("onClicked");
|
||||
|
|
@ -137,18 +138,22 @@ namespace Touka
|
|||
{
|
||||
TKGDebugger.LogDebug("onSkip");
|
||||
}
|
||||
|
||||
public void onLoaded()
|
||||
{
|
||||
TKGDebugger.LogDebug("onLoaded");
|
||||
}
|
||||
|
||||
public void onLoadFail(int code, string msg)
|
||||
{
|
||||
TKGDebugger.LogDebug("onLoadFail");
|
||||
}
|
||||
|
||||
public void onShow()
|
||||
{
|
||||
TKGDebugger.LogDebug("onShow");
|
||||
}
|
||||
|
||||
public void onShowFail(int code, string msg)
|
||||
{
|
||||
TKGDebugger.LogDebug("onShowFail");
|
||||
|
|
@ -156,7 +161,8 @@ namespace Touka
|
|||
if (code == (int)AdShowFailCodeType.AdIsNotReady)
|
||||
{
|
||||
TKGDebugger.LogDebug("iv show failed - AdIsNotReady");
|
||||
}else if(code == (int)AdShowFailCodeType.AdIsReadyCannotShow)
|
||||
}
|
||||
else if (code == (int)AdShowFailCodeType.AdIsReadyCannotShow)
|
||||
{
|
||||
TKGDebugger.LogDebug("iv show failed - AdIsReadyCannotShow");
|
||||
}
|
||||
|
|
@ -181,12 +187,15 @@ namespace Touka
|
|||
/// </summary>
|
||||
public class AndroidRewardADTKGAdCallback : AndroidJavaProxy
|
||||
{
|
||||
public AndroidRewardADTKGAdCallback() : base("com.touka.tkg.idal.ITKGRewardADCallback") { }
|
||||
public AndroidRewardADTKGAdCallback() : base("com.touka.tkg.idal.ITKGRewardADCallback")
|
||||
{
|
||||
}
|
||||
|
||||
public void onClosed()
|
||||
{
|
||||
TKGDebugger.LogDebug("AndroidRewardADTKGAdCallback onClosed");
|
||||
}
|
||||
|
||||
public void onClicked()
|
||||
{
|
||||
TKGDebugger.LogDebug("AndroidRewardADTKGAdCallback onClicked");
|
||||
|
|
@ -204,14 +213,17 @@ namespace Touka
|
|||
{
|
||||
TKGDebugger.LogDebug("AndroidRewardADTKGAdCallback onSkip");
|
||||
}
|
||||
|
||||
public void onLoaded()
|
||||
{
|
||||
TKGDebugger.LogDebug("AndroidRewardADTKGAdCallback onLoaded");
|
||||
}
|
||||
|
||||
public void onLoadFail(int code, string msg)
|
||||
{
|
||||
TKGDebugger.LogDebug("AndroidRewardADTKGAdCallback onLoadFail, code : " + code + " , msg : " + msg);
|
||||
}
|
||||
|
||||
public void onShow()
|
||||
{
|
||||
TKGDebugger.LogDebug("AndroidRewardADTKGAdCallback onShow");
|
||||
|
|
@ -268,32 +280,40 @@ namespace Touka
|
|||
/// </summary>
|
||||
public class AndroidBannerADTKGAdCallback : AndroidJavaProxy
|
||||
{
|
||||
public AndroidBannerADTKGAdCallback() : base("com.touka.tkg.idal.ITKGAdCallback") { }
|
||||
public AndroidBannerADTKGAdCallback() : base("com.touka.tkg.idal.ITKGAdCallback")
|
||||
{
|
||||
}
|
||||
|
||||
public void onClosed()
|
||||
{
|
||||
TKGDebugger.LogDebug("onClosed");
|
||||
}
|
||||
|
||||
public void onClicked()
|
||||
{
|
||||
TKGDebugger.LogDebug("onClicked");
|
||||
}
|
||||
|
||||
public void onSkip()
|
||||
{
|
||||
TKGDebugger.LogDebug("onSkip");
|
||||
}
|
||||
|
||||
public void onLoaded()
|
||||
{
|
||||
TKGDebugger.LogDebug("onLoaded");
|
||||
}
|
||||
|
||||
public void onLoadFail(int code, string msg)
|
||||
{
|
||||
TKGDebugger.LogDebug("onLoadFail, code : " + code + " , msg : " + msg);
|
||||
}
|
||||
|
||||
public void onShow()
|
||||
{
|
||||
TKGDebugger.LogDebug("onShow");
|
||||
}
|
||||
|
||||
public void onShowFail(int code, string msg)
|
||||
{
|
||||
TKGDebugger.LogDebug("onShowFail, code : " + code + " , msg : " + msg);
|
||||
|
|
@ -305,16 +325,20 @@ namespace Touka
|
|||
/// </summary>
|
||||
public class AndroidTKGCommonCalllback : AndroidJavaProxy
|
||||
{
|
||||
public AndroidTKGCommonCalllback() : base("com.touka.tkg.idal.TKGCalllback") { }
|
||||
public AndroidTKGCommonCalllback() : base("com.touka.tkg.idal.TKGCalllback")
|
||||
{
|
||||
}
|
||||
|
||||
public void onCall(int _code, string _msg)
|
||||
{
|
||||
TKGDebugger.LogDebug("TKGCallback onCall, code : " + _code + " , msg : " + _msg);
|
||||
if(TKGSDKCallback.mTKGCommonCallback != null)
|
||||
|
||||
Loom.QueueOnMainThread(pObj =>
|
||||
{
|
||||
if (TKGSDKCallback.mTKGCommonCallback == null) return;
|
||||
TKGSDKCallback.mTKGCommonCallback.Invoke((CommonCallbackCode)_code, _msg);
|
||||
TKGSDKCallback.mTKGCommonCallback = null;
|
||||
}
|
||||
}, "");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -323,16 +347,21 @@ namespace Touka
|
|||
/// </summary>
|
||||
public class AndroidTKGUserSourceCalllback : AndroidJavaProxy
|
||||
{
|
||||
public AndroidTKGUserSourceCalllback() : base("com.touka.tkg.idal.UserSourceCallback") { }
|
||||
public AndroidTKGUserSourceCalllback() : base("com.touka.tkg.idal.UserSourceCallback")
|
||||
{
|
||||
}
|
||||
|
||||
public void onResult(bool _isOrganic, string _userSource)
|
||||
{
|
||||
TKGDebugger.LogDebug("TKGCallback onCall, isOrganic : " + _isOrganic + " , userSource : " + _userSource);
|
||||
if(TKGSDKCallback.mTKGUserSourceCallback != null)
|
||||
Loom.QueueOnMainThread((pObj) =>
|
||||
{
|
||||
if (TKGSDKCallback.mTKGUserSourceCallback != null)
|
||||
{
|
||||
TKGSDKCallback.mTKGUserSourceCallback.Invoke(_isOrganic, _userSource);
|
||||
TKGSDKCallback.mTKGUserSourceCallback = null;
|
||||
}
|
||||
}, "");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -342,15 +371,191 @@ namespace Touka
|
|||
/// </summary>
|
||||
public class AndroidTKGUserSourceCalllbackWithCampaignName : AndroidJavaProxy
|
||||
{
|
||||
public AndroidTKGUserSourceCalllbackWithCampaignName() : base("com.touka.tkg.idal.UserSourceCallbackWithType") { }
|
||||
public AndroidTKGUserSourceCalllbackWithCampaignName() : base("com.touka.tkg.idal.UserSourceCallbackWithType")
|
||||
{
|
||||
}
|
||||
|
||||
public void onResult(bool _isOrganic, string _userSource,string campaignName)
|
||||
public void onResult(bool _isOrganic, string _userSource, string campaignName)
|
||||
{
|
||||
TKGDebugger.LogDebug("TKGCallback onCall, isOrganic : " + _isOrganic + " , userSource : " + _userSource + " , campaignName : " + campaignName);
|
||||
if(TKGSDKCallback.mTKGUserSourceCallbackWithCampaignName != null)
|
||||
TKGDebugger.LogDebug("TKGCallback onCall, isOrganic : " + _isOrganic + " , userSource : " + _userSource +
|
||||
" , campaignName : " + campaignName);
|
||||
|
||||
Loom.QueueOnMainThread(_ =>
|
||||
{
|
||||
TKGSDKCallback.mTKGUserSourceCallbackWithCampaignName.Invoke(_isOrganic, _userSource,campaignName);
|
||||
if (TKGSDKCallback.mTKGUserSourceCallbackWithCampaignName == null) return;
|
||||
TKGSDKCallback.mTKGUserSourceCallbackWithCampaignName.Invoke(_isOrganic, _userSource, campaignName);
|
||||
TKGSDKCallback.mTKGUserSourceCallbackWithCampaignName = null;
|
||||
}, "");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// FunctionSwitchCalllback
|
||||
/// </summary>
|
||||
public class AndroidFunctionSwitchCalllback : AndroidJavaProxy
|
||||
{
|
||||
public AndroidFunctionSwitchCalllback() : base("com.touka.tkg.idal.GameFunctionSwitchCallback")
|
||||
{
|
||||
}
|
||||
|
||||
public void onFunctionSwitchResult(string _functionKey, bool _functionSwitch)
|
||||
{
|
||||
FunctionType enumType = (FunctionType)Enum.Parse(typeof(FunctionType), _functionKey);
|
||||
|
||||
if (TKGSDKCallback.mFunctionSwitchCalllback != null)
|
||||
{
|
||||
Loom.QueueOnMainThread(
|
||||
_ => { TKGSDKCallback.mFunctionSwitchCalllback?.Invoke(enumType, _functionSwitch); }, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// FunctionSwitchCalllback
|
||||
/// </summary>
|
||||
public class AndroidLoginCalllback : AndroidJavaProxy
|
||||
{
|
||||
private bool _isAutoLogin;
|
||||
|
||||
public AndroidLoginCalllback(bool isAutoLogin = false) : base("com.touka.tkg.idal.ITKGLoginCallback")
|
||||
{
|
||||
_isAutoLogin = isAutoLogin;
|
||||
}
|
||||
|
||||
public void onLoginResult(int _code, string _msg, int _loginType, string _userId, string _token, string _email,
|
||||
string _displayName, string _photoUrl)
|
||||
{
|
||||
TKGDebugger.LogDebug("AndroidLoginCalllback onLoginResult, code : " + _code
|
||||
+ " , msg : " + _msg
|
||||
+ " , _loginType : " + _loginType
|
||||
+ " , _userId : " + _userId
|
||||
+ " , _token : " + _token
|
||||
+ " , _email : " + _email
|
||||
+ " , _displayName : " + _displayName
|
||||
+ " , _photoUrl : " + _photoUrl
|
||||
);
|
||||
TKGDebugger.LogDebug($"is auto login {_isAutoLogin}");
|
||||
LoginStatus loginStatusEnum = (LoginStatus)Enum.ToObject(typeof(LoginStatus), _code);
|
||||
LoginType loginTypeEnum = (LoginType)Enum.ToObject(typeof(LoginType), _loginType);
|
||||
Loom.QueueOnMainThread(pObj =>
|
||||
{
|
||||
if (_isAutoLogin)
|
||||
{
|
||||
TKGSDKCallback.mAutoLoginCallback?.Invoke(loginStatusEnum, loginTypeEnum, _msg, _userId, _token,
|
||||
_email,
|
||||
_displayName, _photoUrl);
|
||||
}
|
||||
else
|
||||
{
|
||||
TKGSDKCallback.mLoginCallback?.Invoke(loginStatusEnum, loginTypeEnum, _msg, _userId, _token, _email,
|
||||
_displayName, _photoUrl);
|
||||
}
|
||||
}, "");
|
||||
}
|
||||
|
||||
|
||||
public void onLogout()
|
||||
{
|
||||
if (null != TKGSDKCallback.mLogoutCallback)
|
||||
{
|
||||
Loom.QueueOnMainThread(pObj => { TKGSDKCallback.mLogoutCallback?.Invoke(); }, "");
|
||||
}
|
||||
}
|
||||
|
||||
public void onDeleteAccount(int code, string userId)
|
||||
{
|
||||
if (null == TKGSDKCallback.mDeleteAccountCallback) return;
|
||||
var codeType = (DeleteStatus)Enum.ToObject(typeof(DeleteStatus), code);
|
||||
Loom.QueueOnMainThread(pObj => { TKGSDKCallback.mDeleteAccountCallback?.Invoke(codeType, userId); }, "");
|
||||
}
|
||||
|
||||
|
||||
public void onBindAccount(int _code, string _msg, int _loginType, string _userId, string _token, string _email,
|
||||
string _displayName, string _photoUrl, string userIds)
|
||||
{
|
||||
TKGDebugger.LogDebug("AndroidLoginCalllback onBindAccount, code : " + _code
|
||||
+ " , msg : " + _msg
|
||||
+ " , _loginType : " + _loginType
|
||||
+ " , _userId : " + _userId
|
||||
+ " , _token : " + _token
|
||||
+ " , _email : " + _email
|
||||
+ " , _displayName : " + _displayName
|
||||
+ " , _photoUrl : " + _photoUrl
|
||||
+ " , userIds : " + userIds
|
||||
);
|
||||
if (null == TKGSDKCallback.mBindAccountCallback) return;
|
||||
var bindAccountStatusEnum = (BindAccountStatus)Enum.ToObject(typeof(BindAccountStatus), _code);
|
||||
var loginTypeEnum = (LoginType)Enum.ToObject(typeof(LoginType), _loginType);
|
||||
var userIdList = userIds.Split(',');
|
||||
Loom.QueueOnMainThread(pObj =>
|
||||
{
|
||||
TKGSDKCallback.mBindAccountCallback?.Invoke(bindAccountStatusEnum, loginTypeEnum, _msg, _userId, _token,
|
||||
_email,
|
||||
_displayName, _photoUrl, userIdList);
|
||||
}, "");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// FunctionSwitchCalllback
|
||||
/// </summary>
|
||||
public class AdsRevenueCallback : AndroidJavaProxy
|
||||
{
|
||||
public AdsRevenueCallback() : base("com.touka.tkg.idal.IAdsRevenueCallback")
|
||||
{
|
||||
}
|
||||
|
||||
public void revenueHandle(string _adsType, string _price, string _currnecy)
|
||||
{
|
||||
// FunctionType enumType = (AdsType)Enum.Parse(typeof(AdsType), _adsType);
|
||||
|
||||
if (TKGSDKCallback.mAdsRevenueCallback != null)
|
||||
{
|
||||
AdsType adsType = AdsType.None;
|
||||
switch (_adsType)
|
||||
{
|
||||
case "1":
|
||||
adsType = AdsType.Splash;
|
||||
break;
|
||||
case "2":
|
||||
adsType = AdsType.Banner;
|
||||
break;
|
||||
case "3":
|
||||
adsType = AdsType.IV;
|
||||
break;
|
||||
case "4":
|
||||
adsType = AdsType.RV;
|
||||
break;
|
||||
case "5":
|
||||
adsType = AdsType.Native;
|
||||
break;
|
||||
}
|
||||
|
||||
Loom.QueueOnMainThread(
|
||||
_ => { TKGSDKCallback.mAdsRevenueCallback?.Invoke(adsType, _price, _currnecy); }, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// FunctionSwitchCalllback
|
||||
/// </summary>
|
||||
public class SecondPurchaseCallback : AndroidJavaProxy
|
||||
{
|
||||
public SecondPurchaseCallback() : base("com.touka.tkg.idal.ISecondPurchaseCallback")
|
||||
{
|
||||
}
|
||||
|
||||
public void onResult(string _orderID,string _poductName, string _productID, bool _result, string _gameExtraParam)
|
||||
{
|
||||
// FunctionType enumType = (AdsType)Enum.Parse(typeof(AdsType), _adsType);
|
||||
|
||||
if (TKGSDKCallback.mSecondPurchaseCallback != null)
|
||||
{
|
||||
Loom.QueueOnMainThread(
|
||||
_ => { TKGSDKCallback.mSecondPurchaseCallback?.Invoke(_orderID, _poductName, _productID, _result, _gameExtraParam); }, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -361,6 +566,4 @@ namespace Touka
|
|||
|
||||
}, "");
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Touka
|
||||
{
|
||||
public class TKGSDKCallbackIOS
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,147 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Touka
|
||||
{
|
||||
public class RequestHandler : MonoBehaviour
|
||||
{
|
||||
private static RequestHandler _instance;
|
||||
|
||||
public static RequestHandler Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_instance != null) return _instance;
|
||||
_instance = FindObjectOfType<RequestHandler>();
|
||||
if (_instance != null) return _instance;
|
||||
var obj = new GameObject();
|
||||
_instance = obj.AddComponent<RequestHandler>();
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = this;
|
||||
}
|
||||
else if (_instance != this)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
DontDestroyOnLoad(gameObject);
|
||||
}
|
||||
|
||||
|
||||
public void SendGetRequest(string url, Dictionary<string, string> headers = null,
|
||||
Action<int, string> callback = null
|
||||
)
|
||||
{
|
||||
StartCoroutine(GetRequestCoroutine(url, headers, callback));
|
||||
}
|
||||
|
||||
public void SendPostRequest(string url, string jsonRequestBody,
|
||||
Dictionary<string, string> headers = null, Action<int, string> callback = null)
|
||||
{
|
||||
StartCoroutine(PostRequestCoroutine(url, jsonRequestBody, headers, callback));
|
||||
}
|
||||
|
||||
private static IEnumerator GetRequestCoroutine(string url, Dictionary<string, string> headers,
|
||||
Action<int, string> callback)
|
||||
{
|
||||
try
|
||||
{
|
||||
var request = (HttpWebRequest)WebRequest.Create(url);
|
||||
request.Method = "GET";
|
||||
|
||||
if (headers != null)
|
||||
{
|
||||
foreach (var header in headers)
|
||||
{
|
||||
request.Headers.Add(header.Key, header.Value);
|
||||
}
|
||||
}
|
||||
|
||||
using (var response = (HttpWebResponse)request.GetResponse())
|
||||
{
|
||||
var responseStream = response.GetResponseStream();
|
||||
if (responseStream == null)
|
||||
{
|
||||
throw new Exception("responseStream is null");
|
||||
}
|
||||
|
||||
using (var reader = new StreamReader(responseStream))
|
||||
{
|
||||
var jsonResponse = reader.ReadToEnd();
|
||||
Debug.Log(jsonResponse);
|
||||
callback?.Invoke(0, jsonResponse);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
callback?.Invoke(-1, e.Message);
|
||||
}
|
||||
|
||||
|
||||
yield return null;
|
||||
}
|
||||
|
||||
private static IEnumerator PostRequestCoroutine(string url, string jsonRequestBody,
|
||||
Dictionary<string, string> headers,
|
||||
Action<int, string> callback)
|
||||
{
|
||||
try
|
||||
{
|
||||
var request = (HttpWebRequest)WebRequest.Create(url);
|
||||
request.Method = "POST";
|
||||
request.ContentType = "application/json";
|
||||
|
||||
if (headers != null)
|
||||
{
|
||||
foreach (var header in headers)
|
||||
{
|
||||
request.Headers.Add(header.Key, header.Value);
|
||||
}
|
||||
}
|
||||
|
||||
var byteArray = Encoding.UTF8.GetBytes(jsonRequestBody);
|
||||
request.ContentLength = byteArray.Length;
|
||||
|
||||
using (var requestStream = request.GetRequestStream())
|
||||
{
|
||||
requestStream.Write(byteArray, 0, byteArray.Length);
|
||||
}
|
||||
|
||||
using (var response = (HttpWebResponse)request.GetResponse())
|
||||
{
|
||||
var responseStream = response.GetResponseStream();
|
||||
if (responseStream == null)
|
||||
{
|
||||
throw new Exception("responseStream is null");
|
||||
}
|
||||
|
||||
using (var reader = new StreamReader(responseStream))
|
||||
{
|
||||
var jsonResponse = reader.ReadToEnd();
|
||||
callback?.Invoke(0, jsonResponse);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
callback?.Invoke(-1, e.Message);
|
||||
}
|
||||
|
||||
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b8ee56e924e14f78b5d238375ebb9b53
|
||||
timeCreated: 1690554307
|
||||
|
|
@ -0,0 +1,272 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace Touka
|
||||
{
|
||||
public class Server : NormalSingleton<Server>
|
||||
{
|
||||
// debug
|
||||
private const string BASE_URL = "https://tk.dgtverse.cn/";
|
||||
|
||||
public void Login(LoginType loginType, Action<int, string, LoginInfo> callback)
|
||||
{
|
||||
var deviceId = PlayerPrefs.GetString("device_id", "");
|
||||
if (string.IsNullOrEmpty(deviceId))
|
||||
{
|
||||
deviceId = SystemInfo.deviceUniqueIdentifier;
|
||||
PlayerPrefs.SetString("device_id", deviceId);
|
||||
}
|
||||
|
||||
var thirdUserId = "";
|
||||
|
||||
if (loginType == LoginType.LOGIN_BY_GUESTER)
|
||||
{
|
||||
thirdUserId = deviceId.Replace("-", "");
|
||||
}
|
||||
else if (loginType == LoginType.LOGIN_BY_GOOGLE)
|
||||
{
|
||||
thirdUserId = PlayerPrefs.GetString("google_user_id");
|
||||
}
|
||||
else if (loginType == LoginType.LOGIN_BY_FACEBOOK)
|
||||
{
|
||||
thirdUserId = PlayerPrefs.GetString("facebook_user_id");
|
||||
}
|
||||
|
||||
var body = new Dictionary<string, object>()
|
||||
{
|
||||
["user_type"] = (int)loginType,
|
||||
["third_uid"] = thirdUserId,
|
||||
["user_id"] = PlayerPrefs.GetString("user_id")
|
||||
};
|
||||
Post("ztp/game/user/login", body, callback);
|
||||
}
|
||||
|
||||
|
||||
private static void Post<T>(string url, Dictionary<string, object> args, Action<int, string, T> callback,
|
||||
Dictionary<string, string> headers = null)
|
||||
{
|
||||
if (args == null)
|
||||
{
|
||||
args = new Dictionary<string, object>();
|
||||
}
|
||||
|
||||
if (headers == null)
|
||||
{
|
||||
headers = new Dictionary<string, string>();
|
||||
}
|
||||
|
||||
AddBaseParameters(args);
|
||||
EncryptionParameters(args);
|
||||
var requestBody = ConvertDictionaryToJson(args);
|
||||
Debug.Log("[server]" + url);
|
||||
Debug.Log("[server]" + requestBody);
|
||||
RequestHandler.Instance.SendPostRequest(BASE_URL + url, requestBody, headers,
|
||||
(code, res) =>
|
||||
{
|
||||
if (code == 0)
|
||||
{
|
||||
var resp = JsonUtility.FromJson<Response<T>>(res);
|
||||
callback(resp.code == 0 ? 0 : resp.code, resp.msg, resp.data);
|
||||
}
|
||||
else
|
||||
{
|
||||
callback.Invoke(code, "", (T)new object());
|
||||
}
|
||||
|
||||
Debug.Log("[server]" + "[res] " + res);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private static void Get<T>(string url, Action<int, string, T> callback,
|
||||
Dictionary<string, string> headers = null)
|
||||
{
|
||||
if (headers == null)
|
||||
{
|
||||
headers = new Dictionary<string, string>();
|
||||
}
|
||||
|
||||
RequestHandler.Instance.SendGetRequest(BASE_URL + url, headers,
|
||||
(code, res) =>
|
||||
{
|
||||
if (code == 0)
|
||||
{
|
||||
var resp = JsonUtility.FromJson<Response<T>>(res);
|
||||
callback(resp.code == 0 ? 0 : resp.code, resp.msg, resp.data);
|
||||
}
|
||||
else
|
||||
{
|
||||
callback.Invoke(code, "", (T)new object());
|
||||
}
|
||||
|
||||
Debug.Log("[server]" + "[res] " + res);
|
||||
});
|
||||
}
|
||||
|
||||
private static string GetMD5Hash(string input)
|
||||
{
|
||||
using (var md5 = MD5.Create())
|
||||
{
|
||||
var inputBytes = Encoding.ASCII.GetBytes(input);
|
||||
var hashBytes = md5.ComputeHash(inputBytes);
|
||||
|
||||
var builder = new StringBuilder();
|
||||
foreach (var t in hashBytes)
|
||||
{
|
||||
builder.Append(t.ToString("x2")); // Convert byte to hexadecimal string
|
||||
}
|
||||
|
||||
return builder.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
private static void EncryptionParameters(Dictionary<string, object> args)
|
||||
{
|
||||
const string secretKey = "tk~!@#$%^&*()_+0708";
|
||||
|
||||
var signString =
|
||||
$"{secretKey}platform={args["platform"]}packagename={args["package_name"]}channel={args["channel"]}appversion={args["app_version"]}appversioncode={args["app_version_code"]}language={args["language"]}ip={args["ip"]}ts={args["ts"]}";
|
||||
var sign = GetMD5Hash(signString);
|
||||
args["sign"] = sign;
|
||||
}
|
||||
|
||||
private static void AddBaseParameters(Dictionary<string, object> args)
|
||||
{
|
||||
args.Add("platform", "Unity");
|
||||
args.Add("package_name", "Unity");
|
||||
args.Add("channel", "Unity");
|
||||
args.Add("app_version", "1.0.0");
|
||||
args.Add("app_version_code", "1");
|
||||
args.Add("language", "ZH");
|
||||
args.Add("ip", "");
|
||||
args.Add("device_id", PlayerPrefs.GetString("device_id"));
|
||||
// var time = (int)Time.time;
|
||||
var currentTime = DateTime.Now;
|
||||
var timeSpan = currentTime - new DateTime(1970, 1, 1, 8, 0, 0, DateTimeKind.Utc);
|
||||
var timestamp = (int)(timeSpan.TotalMilliseconds / 1000);
|
||||
args.Add("ts", "" + timestamp);
|
||||
}
|
||||
|
||||
public static string ConvertDictionaryToJson(Dictionary<string, object> dictionary)
|
||||
{
|
||||
StringBuilder jsonBuilder = new StringBuilder();
|
||||
jsonBuilder.Append("{");
|
||||
|
||||
int count = 0;
|
||||
|
||||
foreach (KeyValuePair<string, object> kvp in dictionary)
|
||||
{
|
||||
string key = kvp.Key;
|
||||
object value = kvp.Value;
|
||||
|
||||
jsonBuilder.AppendFormat("\"{0}\":", key);
|
||||
|
||||
if (value is int || value is float || value is bool)
|
||||
{
|
||||
jsonBuilder.Append(value.ToString().ToLower());
|
||||
}
|
||||
else if (value is string)
|
||||
{
|
||||
jsonBuilder.AppendFormat("\"{0}\"", value);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Handle other types or nested dictionaries recursively
|
||||
Dictionary<string, object> nestedDictionary = value as Dictionary<string, object>;
|
||||
if (nestedDictionary != null)
|
||||
{
|
||||
string nestedJson = ConvertDictionaryToJson(nestedDictionary);
|
||||
jsonBuilder.Append(nestedJson);
|
||||
}
|
||||
}
|
||||
|
||||
count++;
|
||||
if (count < dictionary.Count)
|
||||
{
|
||||
jsonBuilder.Append(",");
|
||||
}
|
||||
}
|
||||
|
||||
jsonBuilder.Append("}");
|
||||
return jsonBuilder.ToString();
|
||||
}
|
||||
|
||||
public void DeleteAccount(string userId, Action<int, string> callback)
|
||||
{
|
||||
var args = new Dictionary<string, object> { { "user_id", userId } };
|
||||
|
||||
Post<object>("ztp/game/user/delete", args,
|
||||
(code, msg, obj) => { callback.Invoke(code, code == 0 ? userId : msg); });
|
||||
}
|
||||
|
||||
public void SaveCloudArchiving(string userId, string token, string content, Action<int, string> callback)
|
||||
{
|
||||
var args = new Dictionary<string, object>
|
||||
{
|
||||
{ "user_id", userId },
|
||||
{ "token", token },
|
||||
{ "content", content }
|
||||
};
|
||||
|
||||
var headers = new Dictionary<string, string> { { "Authorization", "a5ca9093ac792ed386b641281eded3b1" } };
|
||||
|
||||
Post<object>("ztp/third/game/user/progress/save", args, (code, msg, obj) => { callback.Invoke(code, msg); },
|
||||
headers);
|
||||
}
|
||||
|
||||
public void DetailCloudArchiving(string userId, string token, Action<int, string, string> callback)
|
||||
{
|
||||
var headers = new Dictionary<string, string> { { "Authorization", "a5ca9093ac792ed386b641281eded3b1" } };
|
||||
Get<Content>($"ztp/third/game/user/progress/detail?user_id={userId}&token={token}",
|
||||
(code, msg, content) => { callback(code, msg, content.content); }, headers);
|
||||
}
|
||||
|
||||
public void Bind(LoginType loginType, BindType bindType, string thirdUid, string userId,
|
||||
Action<int, string, Bind> callback)
|
||||
{
|
||||
var args = new Dictionary<string, object>
|
||||
{
|
||||
{ "user_type", (int)loginType },
|
||||
{ "third_uid", thirdUid },
|
||||
{ "user_id", userId },
|
||||
{ "is_force", (int)bindType },
|
||||
};
|
||||
Post("ztp/game/user/bind", args, callback);
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public struct Response<T>
|
||||
{
|
||||
public int code;
|
||||
public string msg;
|
||||
public T data;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public struct LoginInfo
|
||||
{
|
||||
public string user_id;
|
||||
public string token;
|
||||
public int user_type;
|
||||
public int first_login;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public struct Bind
|
||||
{
|
||||
public string user_id;
|
||||
public string token;
|
||||
public string[] user_ids;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public struct Content
|
||||
{
|
||||
public string content;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 814eb8c144e4424ea0e312f938df7fab
|
||||
timeCreated: 1690559479
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"dependencies": {
|
||||
"com.unity.2d.sprite": "1.0.0",
|
||||
"com.unity.collab-proxy": "1.14.15",
|
||||
"com.unity.collab-proxy": "2.0.5",
|
||||
"com.unity.ide.rider": "1.2.1",
|
||||
"com.unity.ide.visualstudio": "2.0.14",
|
||||
"com.unity.ide.vscode": "1.2.5",
|
||||
|
|
|
|||
|
|
@ -7,18 +7,18 @@
|
|||
"dependencies": {}
|
||||
},
|
||||
"com.unity.collab-proxy": {
|
||||
"version": "1.14.15",
|
||||
"version": "2.0.5",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {},
|
||||
"url": "https://packages.unity.cn"
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.ext.nunit": {
|
||||
"version": "1.0.6",
|
||||
"depth": 1,
|
||||
"source": "registry",
|
||||
"dependencies": {},
|
||||
"url": "https://packages.unity.cn"
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.ide.rider": {
|
||||
"version": "1.2.1",
|
||||
|
|
@ -27,7 +27,7 @@
|
|||
"dependencies": {
|
||||
"com.unity.test-framework": "1.1.1"
|
||||
},
|
||||
"url": "https://packages.unity.cn"
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.ide.visualstudio": {
|
||||
"version": "2.0.14",
|
||||
|
|
@ -36,14 +36,14 @@
|
|||
"dependencies": {
|
||||
"com.unity.test-framework": "1.1.9"
|
||||
},
|
||||
"url": "https://packages.unity.cn"
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.ide.vscode": {
|
||||
"version": "1.2.5",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {},
|
||||
"url": "https://packages.unity.cn"
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.purchasing": {
|
||||
"version": "4.1.3",
|
||||
|
|
@ -57,7 +57,7 @@
|
|||
"com.unity.modules.androidjni": "1.0.0",
|
||||
"com.unity.services.core": "1.0.1"
|
||||
},
|
||||
"url": "https://packages.unity.cn"
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.services.core": {
|
||||
"version": "1.0.1",
|
||||
|
|
@ -66,7 +66,7 @@
|
|||
"dependencies": {
|
||||
"com.unity.modules.unitywebrequest": "1.0.0"
|
||||
},
|
||||
"url": "https://packages.unity.cn"
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.test-framework": {
|
||||
"version": "1.1.31",
|
||||
|
|
@ -77,7 +77,7 @@
|
|||
"com.unity.modules.imgui": "1.0.0",
|
||||
"com.unity.modules.jsonserialize": "1.0.0"
|
||||
},
|
||||
"url": "https://packages.unity.cn"
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.textmeshpro": {
|
||||
"version": "2.1.6",
|
||||
|
|
@ -86,7 +86,7 @@
|
|||
"dependencies": {
|
||||
"com.unity.ugui": "1.0.0"
|
||||
},
|
||||
"url": "https://packages.unity.cn"
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.timeline": {
|
||||
"version": "1.2.18",
|
||||
|
|
@ -98,7 +98,7 @@
|
|||
"com.unity.modules.audio": "1.0.0",
|
||||
"com.unity.modules.particlesystem": "1.0.0"
|
||||
},
|
||||
"url": "https://packages.unity.cn"
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.ugui": {
|
||||
"version": "1.0.0",
|
||||
|
|
@ -242,6 +242,18 @@
|
|||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.ui": "1.0.0",
|
||||
"com.unity.modules.imgui": "1.0.0",
|
||||
"com.unity.modules.jsonserialize": "1.0.0",
|
||||
"com.unity.modules.uielementsnative": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.uielementsnative": {
|
||||
"version": "1.0.0",
|
||||
"depth": 1,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.ui": "1.0.0",
|
||||
"com.unity.modules.imgui": "1.0.0",
|
||||
"com.unity.modules.jsonserialize": "1.0.0"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,14 +12,19 @@ MonoBehaviour:
|
|||
m_Script: {fileID: 13964, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_EnablePreviewPackages: 0
|
||||
m_EnablePackageDependencies: 0
|
||||
m_AdvancedSettingsExpanded: 1
|
||||
m_ScopedRegistriesSettingsExpanded: 1
|
||||
oneTimeWarningShown: 0
|
||||
m_Registries:
|
||||
- m_Id: main
|
||||
m_Name:
|
||||
m_Url: https://packages.unity.cn
|
||||
m_Url: https://packages.unity.com
|
||||
m_Scopes: []
|
||||
m_IsDefault: 1
|
||||
m_Capabilities: 7
|
||||
m_ConfigSource: 0
|
||||
m_UserSelectedRegistryName:
|
||||
m_UserAddingNewScopedRegistry: 0
|
||||
m_RegistryInfoDraft:
|
||||
|
|
@ -30,6 +35,8 @@ MonoBehaviour:
|
|||
m_Url:
|
||||
m_Scopes: []
|
||||
m_IsDefault: 0
|
||||
m_Capabilities: 0
|
||||
m_ConfigSource: 0
|
||||
m_Modified: 0
|
||||
m_Name:
|
||||
m_Url:
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
m_EditorVersion: 2019.4.38f1c1
|
||||
m_EditorVersionWithRevision: 2019.4.38f1c1 (df80985e05f0)
|
||||
m_EditorVersion: 2020.3.45f1
|
||||
m_EditorVersionWithRevision: 2020.3.45f1 (660cd1701bd5)
|
||||
|
|
|
|||
|
|
@ -9,8 +9,7 @@ UnityConnectSettings:
|
|||
m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events
|
||||
m_EventUrl: https://cdp.cloud.unity3d.com/v1/events
|
||||
m_ConfigUrl: https://config.uca.cloud.unity3d.com
|
||||
m_CNEventUrl: https://cdp.cloud.unity.cn/v1/events
|
||||
m_CNConfigUrl: https://cdp.cloud.unity.cn/config
|
||||
m_DashboardUrl: https://dashboard.unity3d.com
|
||||
m_TestInitMode: 0
|
||||
CrashReportingSettings:
|
||||
m_EventUrl: https://perf-events.cloud.unity.cn
|
||||
|
|
@ -24,6 +23,7 @@ UnityConnectSettings:
|
|||
m_Enabled: 1
|
||||
m_TestMode: 0
|
||||
m_InitializeOnStartup: 1
|
||||
m_PackageRequiringCoreStatsPresent: 0
|
||||
UnityAdsSettings:
|
||||
m_Enabled: 0
|
||||
m_InitializeOnStartup: 1
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!890905787 &1
|
||||
VersionControlSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
m_Mode: Visible Meta Files
|
||||
m_CollabEditorSettings:
|
||||
inProgressEnabled: 1
|
||||
Binary file not shown.
Loading…
Reference in New Issue