升级TKGSDK2.2.6

This commit is contained in:
yangjing 2022-09-13 11:26:55 +08:00
parent 726693c408
commit f89cffb684
12 changed files with 318 additions and 48 deletions

View File

@ -182,6 +182,7 @@ public class TKGSDKManager : TKGSingleton<TKGSDKManager>
}
else
{
m_sdkInterface.SetShowSDKToast(showSDKToast);
m_sdkInterface.ShowRewardAd(_adPos, _rewardCallback, _showFailedCallback);
}
}
@ -573,6 +574,11 @@ public class TKGSDKManager : TKGSingleton<TKGSDKManager>
#region others
public void Toast(string text)
{
m_sdkInterface.Toast(text);
}
/// <summary>
/// Set user source listener
/// only call first can back source
@ -603,5 +609,16 @@ public class TKGSDKManager : TKGSingleton<TKGSDKManager>
m_sdkInterface.SetTKGCommonCallback(_commonCallbackAction);
}
#endregion
/// <summary>
/// 注册功能开关回调
/// </summary>
/// <param name="_functionKeys"> 各功能名称 </param>
/// <param name="_functionSwitchCallback"> 回调事件,回来每个功能名称及对应开关 </param>
public void SetFunctionSwitchListener(List<FunctionType> _functionKeys, Action<FunctionType, bool> _functionSwitchCallback)
{
m_sdkInterface.SetFunctionSwitchListener(_functionKeys, _functionSwitchCallback);
}
#endregion
}

View File

@ -76,6 +76,12 @@ namespace Touka
/// <param name="_showFailedCallback">Callback of reward ad show fail</param>
void ShowRewardAd(TKGRVPositionName _adPos, Action<bool> _rewardCallback = null, Action _showFailedCallback = null);
/// <summary>
/// SetShowSDKToast
/// <param name="useSDKToast"> if use sdk toast set true else set false</param>
void SetShowSDKToast(bool _useSDKToast);
/// <summary>
/// Is Ready Reward
/// </summary>
@ -234,6 +240,8 @@ namespace Touka
void OpenPolicyPop();
void Toast(string _text);
/// <summary>
/// shake
/// </summary>
@ -257,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>
@ -307,6 +322,21 @@ namespace Touka
#endregion
}
/// <summary>
/// 功能名称枚举
/// </summary>
public enum FunctionType
{
Function_wangz,
Function_bing,
Function_IA,
Function_IP,
Function_name,
Function_other1,
Function_other2,
Function_other3
}
/// <summary>
/// IV Ad Type
/// Control different frequency interstitial Ads

View File

@ -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()
@ -147,6 +147,17 @@ namespace Touka
TKGNativeInterface.Instance.showRewardAd(_adPos.ToString(), -1);
}
public void Toast(string text) {
TKGNativeInterface.Instance.toast(text);
}
public void SetShowSDKToast(bool _useSDKToast)
{
TKGNativeInterface.Instance.SetShowSDKToast(_useSDKToast);
}
/// <summary>
/// Is Ready Interstitial
/// </summary>
@ -577,6 +588,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>
@ -669,6 +689,7 @@ namespace Touka
TKGNativeInterface.Instance.RemoveNotification(notiId);
#endif
}
#endregion
#endregion
}
}

View File

@ -50,6 +50,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,10 +75,18 @@ public class TGiOSAdManager : MonoBehaviour
IntPtr rvClick = Marshal.GetFunctionPointerForDelegate(rvClickHandler);
rewardAdClickCallback(rvClick);
TKG_InitSDK();
}
// 注册事件
public void setFunctions(string funcs)
{
TKG_SetFuncs(funcs);
}
// 通知
public void registAPNS()
{
@ -166,6 +179,11 @@ public class TGiOSAdManager : MonoBehaviour
TKG_ShowRewardVideo(adPos);
}
public void ShowSDKToast(bool _show)
{
TKG_ShowSDKToast(_show);
}
// native
public void LoadNative(float width, float height)
{
@ -212,6 +230,10 @@ public class TGiOSAdManager : MonoBehaviour
TKG_OpenMoreGame();
}
public void Toast(string content)
{
TKG_Toast(content);
}
// 在线参数
public int GetConfigInt(string key, int defaultValue)
@ -399,7 +421,31 @@ 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("yangwu 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);
}
}
}
// dll
[DllImport("__Internal")]
private static extern void TKG_SetFuncs(string funcs);
[DllImport("__Internal")]
private static extern void TKG_Shake(int mType, float mIntensity);
@ -448,6 +494,9 @@ public class TGiOSAdManager : MonoBehaviour
[DllImport("__Internal")]
private static extern void TKG_OpenMoreGame();
[DllImport("__Internal")]
private static extern void TKG_Toast(string str);
// ads
[DllImport("__Internal")]
private static extern void TKG_LoadBanner();
@ -479,6 +528,9 @@ public class TGiOSAdManager : MonoBehaviour
[DllImport("__Internal")]
private static extern void TKG_ShowRewardVideo(string adPos);
[DllImport("__Internal")]
private static extern void TKG_ShowSDKToast(bool _show);
[DllImport("__Internal")]
private static extern void TKG_LoadNative(float width, float height);
@ -550,6 +602,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);

View File

@ -584,7 +584,60 @@ namespace Touka
PlistElementDict dic126;
dic126 = URLWhiteListArr2.AddDict();
dic126.SetString("SKAdNetworkIdentifier", "pwdxu55a5a.skadnetwork");
#endregion
PlistElementDict dic127;
dic127 = URLWhiteListArr2.AddDict();
dic127.SetString("SKAdNetworkIdentifier", "b9bk5wbcq9.skadnetwork");
PlistElementDict dic128;
dic128 = URLWhiteListArr2.AddDict();
dic128.SetString("SKAdNetworkIdentifier", "x5l83yy675.skadnetwork");
PlistElementDict dic129;
dic129 = URLWhiteListArr2.AddDict();
dic129.SetString("SKAdNetworkIdentifier", "x2jnk7ly8j.skadnetwork");
PlistElementDict dic130;
dic130 = URLWhiteListArr2.AddDict();
dic130.SetString("SKAdNetworkIdentifier", "4w7y6s5ca2.skadnetwork");
PlistElementDict dic131;
dic131 = URLWhiteListArr2.AddDict();
dic131.SetString("SKAdNetworkIdentifier", "7fmhfwg9en.skadnetwork");
PlistElementDict dic132;
dic132 = URLWhiteListArr2.AddDict();
dic132.SetString("SKAdNetworkIdentifier", "qu637u8glc.skadnetwork");
PlistElementDict dic133;
dic133 = URLWhiteListArr2.AddDict();
dic133.SetString("SKAdNetworkIdentifier", "krvm3zuq6h.skadnetwork");
PlistElementDict dic134;
dic134 = URLWhiteListArr2.AddDict();
dic134.SetString("SKAdNetworkIdentifier", "3l6bd9hu43.skadnetwork");
PlistElementDict dic135;
dic135 = URLWhiteListArr2.AddDict();
dic135.SetString("SKAdNetworkIdentifier", "a8cz6cu7e5.skadnetwork");
PlistElementDict dic136;
dic136 = URLWhiteListArr2.AddDict();
dic136.SetString("SKAdNetworkIdentifier", "dkc879ngq3.skadnetwork");
PlistElementDict dic137;
dic137 = URLWhiteListArr2.AddDict();
dic137.SetString("SKAdNetworkIdentifier", "m5mvw97r93.skadnetwork");
PlistElementDict dic138;
dic138 = URLWhiteListArr2.AddDict();
dic138.SetString("SKAdNetworkIdentifier", "vcra2ehyfk.skadnetwork");
PlistElementDict dic139;
dic139 = URLWhiteListArr2.AddDict();
dic139.SetString("SKAdNetworkIdentifier", "x5l83yy675.skadnetwork");
#endregion
PlistElementArray urlTypes = plist.root.CreateArray("CFBundleURLTypes");
@ -611,47 +664,28 @@ namespace Touka
string mainTarget = pbxProject.TargetGuidByName(targetName);
#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/BUAdSDK.bundle", "Frameworks/Plugins/ToukaGames/Plugins/iOS/ToponSDK/pangle_China/BUAdSDK.bundle", PBXSourceTree.Sdk)); pbxProject.WriteToFile(projectPath);
//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>"))
{
SplashScreenController.WriteBelow("#include \"SplashScreen.h\"", "#import <TKGUNITYSDK/TONativeSplashHelper.h>");
SplashScreenController.WriteBelow("void HideSplashScreen()\n{", "[[TONativeSplashHelper helper]showSplashInLaunch];");
}
#endif
#if USE_SPLASH
ToukaClassHelper SplashScreenControllers = new ToukaClassHelper(_path + "/Classes/UI/SplashScreen.mm");
if (!SplashScreenControllers.HasBolow("#import <TKGSplashSDK/TKGSplashManager.h>"))
{
SplashScreenControllers.WriteBelow("#include \"SplashScreen.h\"", "#import <TKGSplashSDK/TKGSplashManager.h>");
SplashScreenControllers.WriteBelow("void HideSplashScreen()\n{", "[[TKGSplashManager manager]showSplashInLaunch];");
}
ToukaClassHelper UnityAppController = new ToukaClassHelper(_path + "/Classes/UnityAppController.mm");
if (!UnityAppController.HasBolow("[[TKGSplashManager manager] showSplashInEnterForground];"))
ToukaClassHelper SplashScreenControllers = new ToukaClassHelper(_path + "/Classes/UI/SplashScreen.mm");
if (!SplashScreenControllers.HasBolow("#import <TKGNativeInterfaceSDK/TKGSplashAd.h>"))
{
UnityAppController.WriteBelow("#import \"UnityAppController.h\"", "\n#import <TKGSplashSDK/TKGSplashManager.h>");
UnityAppController.WriteBelow("UnityPause(0);", "\n[[TKGSplashManager manager] showSplashInEnterForground];");
SplashScreenControllers.WriteBelow("#include \"SplashScreen.h\"", "#import <TKGNativeInterfaceSDK/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 <TKGNativeInterfaceSDK/TKGSplashAd.h>");
UnityAppController.WriteBelow("UnityPause(0);", "\n[TKGSplashAd showsplashAdInEnterForground];");
}
}
#endif
}

View File

@ -151,8 +151,7 @@ public class ToukaAnalyticsBuildPostProcessor
proj.SetBuildProperty(target, "GCC_C_LANGUAGE_STANDARD", "gnu99");
proj.SetBuildProperty(target, "GCC_ENABLE_OBJC_EXCEPTIONS","YES");
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))");
proj.SetBuildProperty(target, "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES", "NO");
File.WriteAllText(projPath, proj.WriteToString());
#endif
}
@ -176,11 +175,14 @@ public class ToukaAnalyticsBuildPostProcessor
plist.ReadFromFile(plistPath);
#if !AppStore_GB
plist.root.SetString("NSLocationAlwaysUsageDescription", "为了更好的体验游戏");
plist.root.SetString("NSCameraUsageDescription", "为了更好的体验游戏");
plist.root.SetString("NSLocationWhenInUseUsageDescription", "为了更好的体验游戏");
plist.root.SetString("NSUserTrackingUsageDescription", "该标识符将用于向您投放个性化广告");
plist.root.SetString("NSPhotoLibraryUsageDescription", "为了更好的体验游戏,请允许APP保存图片到您的相册");
#else
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");
plist.root.SetString("NSUserTrackingUsageDescription", "This identifier will be used to deliver personalized ads to you.");
plist.root.SetString("NSPhotoLibraryUsageDescription", "In order to experience the game better, please allow the APP to save pictures to your album.");

View File

@ -11,7 +11,7 @@ namespace Touka
{
private static TKGNativeInterface _instance;
private string UnitySDKVersion = "2.2.5";
private string UnitySDKVersion = "2.2.6";
public static TKGNativeInterface Instance
{
@ -109,6 +109,8 @@ namespace Touka
/// <param name="_itemCount"></param>
public abstract void showRewardAd(string _adPos, int _itemCount = -1);
public abstract void SetShowSDKToast(bool _useSDKToast);
/// <summary>
/// Show Reward Ad
/// </summary>
@ -445,6 +447,11 @@ 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
}
}

View File

@ -205,6 +205,14 @@ namespace Touka
#endif
}
public override void SetShowSDKToast(bool _useSDKToast)
{
#if UNITY_ANDROID
SDKCall("setShowSDKRewardTips", _useSDKToast);
#endif
}
public override void ShowNativeAd(RectTransform pRect, Camera pCam = null, string pAdPos = "")
{
#if UNITY_ANDROID
@ -650,7 +658,7 @@ namespace Touka
/// <param name="_content"></param>
public override void toast(string _content)
{
SDKCall("toast");
SDKCall("dialogTips",_content);
}
/// <summary>
@ -677,17 +685,17 @@ namespace Touka
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
@ -710,7 +718,25 @@ 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);
}
#endregion
}
}

View File

@ -544,6 +544,16 @@ namespace Touka
}
public override void SetShowSDKToast(bool _useSDKToast)
{
}
public override void SetFunctionSwitchCalllback(List<FunctionType> _functionKeys, AndroidFunctionSwitchCalllback _functionSwitchCalllback)
{
}
#endregion
}

View File

@ -159,6 +159,13 @@ namespace Touka
#endif
}
public override void SetShowSDKToast(bool _useSDKToast)
{
#if !UNITY_EDITOR
TGiOSAdManager.Instance.ShowSDKToast(_useSDKToast);
#endif
}
/// <summary>
/// Show FullScreen Ad(is RV without reward callback)
/// </summary>
@ -599,7 +606,9 @@ namespace Touka
/// <param name="_content"></param>
public override void toast(string _content)
{
#if !UNITY_EDITOR
TGiOSAdManager.Instance.Toast(_content);
#endif
}
/// <summary>
@ -629,7 +638,28 @@ 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);
}
#endregion

View File

@ -21,6 +21,9 @@ 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;
@ -99,6 +102,17 @@ namespace Touka
mTKGUserSourceCallbackWithCampaignName = _userSourceCallbackWithCampaignNameAction;
}
/// <summary>
/// Set Function Switch Calllback
/// </summary>
/// <param name="_userSourceCallbackAction"></param>
public static void SetFunctionSwitchCalllback(Action<FunctionType, bool> _functionSwitchCalllback)
{
mFunctionSwitchCalllback = _functionSwitchCalllback;
}
public static void SetRewardClickCallback(Action _rewardClickAction)
{
mRewardClickCallback = _rewardClickAction;

View File

@ -1,4 +1,5 @@
using System.Collections;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@ -355,6 +356,25 @@ namespace Touka
}
}
/// <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)
{
TKGSDKCallback.mFunctionSwitchCalllback.Invoke(enumType, _functionSwitch);
}
}
}
/*
Loom.QueueOnMainThread((pObj) =>
{