1033 lines
30 KiB
C#
1033 lines
30 KiB
C#
#if UNITY_ANDROID
|
||
|
||
using System;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using UnityEngine;
|
||
|
||
namespace Touka
|
||
{
|
||
/// <summary>
|
||
/// TKG Native SDK Android platform interface call
|
||
/// </summary>
|
||
public class TKGNativeInterfaceAndroid : TKGNativeInterface
|
||
{
|
||
private AndroidJavaObject jo;
|
||
|
||
public TKGNativeInterfaceAndroid()
|
||
{
|
||
// java interface class
|
||
using (AndroidJavaClass jc = new AndroidJavaClass("com.touka.tkg.TKGProxyJava"))
|
||
{
|
||
jo = jc.CallStatic<AndroidJavaObject>("getInstance");
|
||
}
|
||
}
|
||
|
||
private T SDKCall<T>(string _method, params object[] _param)
|
||
{
|
||
try
|
||
{
|
||
return jo.Call<T>(_method, _param);
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
Debug.LogError(e);
|
||
}
|
||
|
||
return default(T);
|
||
}
|
||
|
||
private void SDKCall(string _method, params object[] _param)
|
||
{
|
||
try
|
||
{
|
||
jo.Call(_method, _param);
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
Debug.LogError(e);
|
||
}
|
||
}
|
||
|
||
#region init
|
||
|
||
/// <summary>
|
||
/// init
|
||
/// </summary>
|
||
/// <param name="_initCallback"></param>
|
||
public override void Init(Action _initCallback = null)
|
||
{
|
||
TKGDebugger.LogDebug("init ----- 00");
|
||
base.Init(_initCallback);
|
||
TKGDebugger.LogDebug("init ----- 01");
|
||
SetBannerAdCallback(new AndroidBannerADTKGAdCallback());
|
||
TKGDebugger.LogDebug("init ----- 01 ------- a");
|
||
setInterstitalAdCallback(new AndroidInterADTKGAdCallback());
|
||
TKGDebugger.LogDebug("init ----- 01 ------- b");
|
||
SetRewardAdCallback(new AndroidRewardADTKGAdCallback());
|
||
TKGDebugger.LogDebug("init ----- 01 ------- c");
|
||
SetSDKCommonCallback(new AndroidTKGCommonCalllback());
|
||
TKGDebugger.LogDebug("init ----- 01 ------- d");
|
||
SetSecondPurchaseCallback();
|
||
SetAdsRevenueCallback();
|
||
SDKCall("init", new AndroidProxyCallback());
|
||
TKGDebugger.LogDebug("init ----- 02");
|
||
}
|
||
|
||
private void SetSecondPurchaseCallback()
|
||
{
|
||
#if USE_IAP
|
||
SDKCall("setSecondPurchaseCallback", new SecondPurchaseCallback());
|
||
#endif
|
||
}
|
||
private void SetAdsRevenueCallback()
|
||
{
|
||
SDKCall("setAdsRevenueCallback", new AdsRevenueCallback());
|
||
}
|
||
|
||
#endregion
|
||
|
||
/// <summary>
|
||
/// Get Channel
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public override string GetChannel()
|
||
{
|
||
#if UNITY_ANDROID
|
||
return SDKCall<string>("getChannel");
|
||
#endif
|
||
return "AndroidRoot";
|
||
}
|
||
|
||
#region Ads
|
||
|
||
public override void PurchasedRemoveAds()
|
||
{
|
||
#if UNITY_ANDROID
|
||
SDKCall("purchasedRemoveAds");
|
||
#endif
|
||
}
|
||
|
||
public override void SetUnitySDKVersion(string sdkVersion)
|
||
{
|
||
#if UNITY_ANDROID
|
||
SDKCall("setUnitySDKVersion", "UnitySDK", sdkVersion);
|
||
#endif
|
||
}
|
||
|
||
#region Ads Show
|
||
|
||
/// <summary>
|
||
/// Show banner Ad
|
||
/// </summary>
|
||
/// <param name="_bannerAlign">bannerAlign</param>
|
||
public override void showBannerAd(TKGBannerAlign _pos)
|
||
{
|
||
int _posIndex = 2;
|
||
if (_pos == TKGBannerAlign.BannerCenterTopAlign)
|
||
{
|
||
_posIndex = 1;
|
||
}
|
||
else if (_pos == TKGBannerAlign.BannerCenterBottomAlign)
|
||
{
|
||
_posIndex = 2;
|
||
}
|
||
#if UNITY_ANDROID
|
||
SDKCall("showBannerAd", _posIndex);
|
||
#endif
|
||
}
|
||
|
||
/// <summary>
|
||
/// Hide Banner Ad
|
||
/// </summary>
|
||
public override void hideBannerAd()
|
||
{
|
||
#if UNITY_ANDROID
|
||
SDKCall("hideBannerAd");
|
||
#endif
|
||
}
|
||
|
||
public override void RemoveNativeAd()
|
||
{
|
||
#if UNITY_ANDROID
|
||
SDKCall("hideNative");
|
||
#endif
|
||
}
|
||
|
||
/// <summary>
|
||
/// Show Interstitial Ad
|
||
/// </summary>
|
||
public override void showInterstitialAd()
|
||
{
|
||
#if UNITY_ANDROID
|
||
SDKCall("showInterstitialAd");
|
||
#endif
|
||
}
|
||
|
||
/// <summary>
|
||
/// Show Interstitial Ad
|
||
/// </summary>
|
||
/// <param name="_adPos"></param>
|
||
public override void showInterstitialAd(string _adPos, IVADType _IvType = IVADType.IV1)
|
||
{
|
||
#if UNITY_ANDROID
|
||
SDKCall("showInterstitialAd", _adPos, (int)_IvType);
|
||
#endif
|
||
}
|
||
|
||
/// <summary>
|
||
/// Show Reward Ad
|
||
/// </summary>
|
||
/// <param name="_adPos"></param>
|
||
/// <param name="_itemCount"></param>
|
||
public override void showRewardAd(string _adPos, int _itemCount = -1)
|
||
{
|
||
#if UNITY_ANDROID
|
||
SDKCall("showRewardAd", _adPos, _itemCount);
|
||
#endif
|
||
}
|
||
|
||
/// <summary>
|
||
/// Show Reward Ad
|
||
/// </summary>
|
||
/// <param name="_adPos"></param>
|
||
/// <param name="_itemCount"></param>
|
||
/// <param name="_extraEvent"></param>
|
||
public override void showRewardAd(string _adPos, int _itemCount, Dictionary<string, string> _extraEvent)
|
||
{
|
||
#if UNITY_ANDROID
|
||
SDKCall("showRewardAd", _adPos, _itemCount, _extraEvent);
|
||
#endif
|
||
}
|
||
|
||
/// <summary>
|
||
/// Show Video Ad
|
||
/// </summary>
|
||
/// <param name="_adPos"></param>
|
||
/// <param name="_itemCount"></param>
|
||
public override void showVideoAd(string _adPos, int _itemCount = -1)
|
||
{
|
||
#if UNITY_ANDROID
|
||
SDKCall("showVideoAd", _adPos, _itemCount);
|
||
#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
|
||
Vector3[] tWorldCorners = new Vector3[4];
|
||
pRect.GetWorldCorners(tWorldCorners);
|
||
|
||
Vector2 tTopLeft = RectTransformUtility.WorldToScreenPoint(pCam, tWorldCorners[1]);
|
||
Vector2 tBottomRight = RectTransformUtility.WorldToScreenPoint(pCam, tWorldCorners[3]);
|
||
float tWidth = Mathf.Abs(tBottomRight.x - tTopLeft.x);
|
||
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);
|
||
#endif
|
||
}
|
||
|
||
#endregion
|
||
|
||
|
||
#region Ads isready
|
||
|
||
/// <summary>
|
||
/// banner isReady
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public override bool isBannerAdReady()
|
||
{
|
||
#if UNITY_ANDROID
|
||
bool isReady = SDKCall<bool>("isBannerAdReady");
|
||
return isReady;
|
||
#else
|
||
return false;
|
||
#endif
|
||
}
|
||
|
||
/// <summary>
|
||
/// Interstitial isReady
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public override bool isInterstitialAdReady()
|
||
{
|
||
#if UNITY_ANDROID
|
||
bool isReady = SDKCall<bool>("isInterstitialAdReady");
|
||
return isReady;
|
||
#else
|
||
return false;
|
||
#endif
|
||
}
|
||
|
||
/// <summary>
|
||
/// Reward isReady
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public override bool isRewardAdReady()
|
||
{
|
||
#if UNITY_ANDROID
|
||
bool isReady = SDKCall<bool>("isRewardAdReady");
|
||
return isReady;
|
||
#else
|
||
return false;
|
||
#endif
|
||
}
|
||
|
||
/// <summary>
|
||
/// FullScreen isReady
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public override bool isVideoAdReady()
|
||
{
|
||
#if UNITY_ANDROID
|
||
bool isReady = SDKCall<bool>("isVideoAdReady");
|
||
return isReady;
|
||
#else
|
||
return false;
|
||
#endif
|
||
}
|
||
|
||
public override bool IsReadyNativeAd()
|
||
{
|
||
#if UNITY_ANDROID
|
||
bool isReady = SDKCall<bool>("isNativeReady");
|
||
return isReady;
|
||
#else
|
||
return false;
|
||
#endif
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region Set ads callback
|
||
|
||
/// <summary>
|
||
/// Set Banner Ad Callback
|
||
/// </summary>
|
||
/// <param name="_bannerCallback"></param>
|
||
public override void SetBannerAdCallback(AndroidBannerADTKGAdCallback _bannerCallback)
|
||
{
|
||
#if UNITY_ANDROID
|
||
SDKCall("setBannerAdCallback", _bannerCallback);
|
||
#endif
|
||
}
|
||
|
||
/// <summary>
|
||
/// Set Interstital Ad Callback
|
||
/// </summary>
|
||
/// <param name="_interCallback"></param>
|
||
public override void setInterstitalAdCallback(AndroidInterADTKGAdCallback _interCallback)
|
||
{
|
||
#if UNITY_ANDROID
|
||
SDKCall("setInterstitalAdCallback", _interCallback);
|
||
#endif
|
||
}
|
||
|
||
/// <summary>
|
||
/// Set reward Ad Callback
|
||
/// </summary>
|
||
/// <param name="_rewardCallback"></param>
|
||
public override void SetRewardAdCallback(AndroidRewardADTKGAdCallback _rewardCallback)
|
||
{
|
||
#if UNITY_ANDROID
|
||
SDKCall("setRewardAdCallback", _rewardCallback);
|
||
#endif
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// Set video Ad Callback(full screen ad, reward ad with no reward callback)
|
||
/// </summary>
|
||
/// <param name="_videoCallback"></param>
|
||
public override void setVideoAdCallback(AndroidInterADTKGAdCallback _videoCallback)
|
||
{
|
||
#if UNITY_ANDROID
|
||
SDKCall("setVideoAdCallback", _videoCallback);
|
||
#endif
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region load ads
|
||
|
||
/// <summary>
|
||
/// load interstitial ad
|
||
/// (retry 3 times, per time interval 10s)
|
||
/// </summary>
|
||
public override void loadInterstitialAD()
|
||
{
|
||
#if UNITY_ANDROID
|
||
SDKCall("loadInterstitialAD");
|
||
#endif
|
||
}
|
||
|
||
/// <summary>
|
||
/// load reward ad
|
||
/// (retry 3 times, per time interval 10s)
|
||
/// </summary>
|
||
public override void loadRewardAD()
|
||
{
|
||
#if UNITY_ANDROID
|
||
SDKCall("loadRewardAD");
|
||
#endif
|
||
}
|
||
|
||
/// <summary>
|
||
/// load video ad
|
||
/// (retry 3 times, per time interval 10s)
|
||
/// </summary>
|
||
public override void loadVideoAD()
|
||
{
|
||
#if UNITY_ANDROID
|
||
SDKCall("loadVideoAD");
|
||
#endif
|
||
}
|
||
|
||
#endregion
|
||
|
||
#endregion
|
||
|
||
|
||
#region Log Event
|
||
|
||
#region Normal
|
||
|
||
/// <summary>
|
||
/// onEvent
|
||
/// </summary>
|
||
/// <param name="_eventName"></param>
|
||
/// <returns></returns>
|
||
public override void onEvent(string _eventName)
|
||
{
|
||
#if UNITY_ANDROID
|
||
SDKCall("onEvent", _eventName);
|
||
#endif
|
||
}
|
||
|
||
/// <summary>
|
||
/// onEvent
|
||
/// </summary>
|
||
/// <param name="_eventName"></param>
|
||
/// <param name="_key01"></param>
|
||
/// <param name="_value01"></param>
|
||
/// <returns></returns>
|
||
public override void onEvent(string _eventName, string _key01, string _value01)
|
||
{
|
||
#if UNITY_ANDROID
|
||
SDKCall("onEvent", _eventName, _key01, _value01);
|
||
#endif
|
||
}
|
||
|
||
/// <summary>
|
||
/// onEvent
|
||
/// </summary>
|
||
/// <param name="_eventName"></param>
|
||
/// <param name="_key01"></param>
|
||
/// <param name="_value01"></param>
|
||
/// <param name="_key02"></param>
|
||
/// <param name="_value02"></param>
|
||
/// <returns></returns>
|
||
public override void onEvent(string _eventName, string _key01, string _value01, string _key02, string _value02)
|
||
{
|
||
#if UNITY_ANDROID
|
||
SDKCall("onEvent", _eventName, _key01, _value01, _key02, _value02);
|
||
#endif
|
||
}
|
||
|
||
/// <summary>
|
||
/// onEvent
|
||
/// </summary>
|
||
/// <param name="_eventName"></param>
|
||
/// <param name="_keyValues"></param>
|
||
public override void onEvent(string _eventName, Dictionary<string, string> _keyValues)
|
||
{
|
||
#if UNITY_ANDROID
|
||
SDKCall("onEvent", _eventName, Analytics.ToJavaHashMap(_keyValues));
|
||
#endif
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region Level Event
|
||
|
||
/// <summary>
|
||
/// Level Start
|
||
/// </summary>
|
||
/// <param name="_levelId"></param>
|
||
public override void LevelStart(string _levelId)
|
||
{
|
||
#if UNITY_ANDROID
|
||
SDKCall("levelStart", _levelId);
|
||
#endif
|
||
}
|
||
|
||
/// <summary>
|
||
/// Level end
|
||
/// </summary>
|
||
/// <param name="_levelId"></param>
|
||
/// <param name="_stageResult"></param>
|
||
public override void LevelEnd(string _levelId, StageResult _stageResult)
|
||
{
|
||
#if UNITY_ANDROID
|
||
SDKCall("levelEnd", _levelId, (int)_stageResult);
|
||
#endif
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region Tracking Event
|
||
|
||
/// <summary>
|
||
/// Log Tracking Event
|
||
/// </summary>
|
||
/// <param name="_eventType"></param>
|
||
public override void LogTrackingEvent(TrackingEventType _eventType)
|
||
{
|
||
#if UNITY_ANDROID
|
||
SDKCall("LogTrackingEvent", (int)_eventType);
|
||
#endif
|
||
}
|
||
|
||
#endregion
|
||
|
||
#endregion
|
||
|
||
#region Online Config
|
||
|
||
/// <summary>
|
||
/// get config - int
|
||
/// </summary>
|
||
/// <param name="_key"></param>
|
||
/// <returns></returns>
|
||
public override int GetConfigInt(string _key, int _default)
|
||
{
|
||
TKGDebugger.LogDebug("int _key : " + _key + " , _default : " + _default);
|
||
int newValue = SDKCall<int>("getConfigInt", _key, _default);
|
||
return newValue;
|
||
}
|
||
|
||
/// <summary>
|
||
/// get config - string
|
||
/// </summary>
|
||
/// <param name="_key"></param>
|
||
/// <returns></returns>
|
||
public override string GetConfigString(string _key, string _default)
|
||
{
|
||
TKGDebugger.LogDebug("string _key : " + _key + " , _default : " + _default);
|
||
string newValue = SDKCall<string>("getConfigString", _key, _default);
|
||
return newValue;
|
||
}
|
||
|
||
/// <summary>
|
||
/// get config - bool
|
||
/// </summary>
|
||
/// <param name="_key"></param>
|
||
/// <returns></returns>
|
||
public override bool GetConfigBool(string _key, bool _default)
|
||
{
|
||
TKGDebugger.LogDebug("bool _key : " + _key + " , _default : " + _default);
|
||
bool newValue = SDKCall<bool>("getConfigBool", _key, _default);
|
||
return newValue;
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region Others (Common)
|
||
|
||
/// <summary>
|
||
/// review
|
||
/// </summary>
|
||
public override void Review()
|
||
{
|
||
SDKCall("review");
|
||
}
|
||
|
||
/// <summary>
|
||
/// open Privacy
|
||
/// </summary>
|
||
public override void OpenPrivacyURL()
|
||
{
|
||
SDKCall("openPrivacy");
|
||
}
|
||
|
||
/// <summary>
|
||
/// open agreement
|
||
/// </summary>
|
||
public override void OpenUserTermURL()
|
||
{
|
||
SDKCall("openAgreement");
|
||
}
|
||
|
||
/// <summary>
|
||
/// open policy pop
|
||
/// </summary>
|
||
public override void OpenPolicyPop()
|
||
{
|
||
SDKCall("openPrivacyDialog");
|
||
}
|
||
|
||
/// <summary>
|
||
/// More Games
|
||
/// </summary>
|
||
public override void OpenMoreGame()
|
||
{
|
||
SDKCall("moreGames");
|
||
}
|
||
|
||
/// <summary>
|
||
/// Set Log Enable
|
||
/// </summary>
|
||
/// <param name="_enable"></param>
|
||
public override void SetLogEnable(bool _enable)
|
||
{
|
||
SDKCall("setEnableLog", _enable);
|
||
}
|
||
|
||
/// <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)
|
||
/// </summary>
|
||
/// <param name="_shakeTime"> shake time </param>
|
||
public override void shake(int _shakeType, float _intensity = 1)
|
||
{
|
||
long tShakeMS = _shakeType * _shakeType * 20 + (int)(_intensity * (_shakeType + 1) * 10);
|
||
SDKCall("shake", tShakeMS);
|
||
}
|
||
|
||
/// <summary>
|
||
/// shake(can repeat)
|
||
/// </summary>
|
||
/// <param name="_repeatTimes"> repeat times : -1 </param>
|
||
/// <param name="_shakeTime"> wait time,shake time(100,1000,100,111)</param>
|
||
//public override void shake(int _repeatTimes, params int[] _shakeTime)
|
||
//{
|
||
// SDKCall("shake", _repeatTimes, _shakeTime);
|
||
//}
|
||
|
||
/// <summary>
|
||
/// cancel shake
|
||
/// </summary>
|
||
public override void cancelShake()
|
||
{
|
||
SDKCall("cancelShake");
|
||
}
|
||
|
||
/// <summary>
|
||
/// Show Tips
|
||
/// Pop-up prompt (the one with black transparent background) unified style, Chinese, Japanese, Korean and English, support multi-language, multi-language text
|
||
///
|
||
/// game judges different languages by itself and passes different strings
|
||
/// </summary>
|
||
/// <param name="_titleStr"> title </param>
|
||
/// <param name="_contentStr"> content </param>
|
||
public override void dialogTips(string _titleStr, string _contentStr = "")
|
||
{
|
||
SDKCall("dialogTips", _titleStr);
|
||
}
|
||
|
||
/// <summary>
|
||
/// Open ULR by Browser
|
||
/// </summary>
|
||
/// <param name="_url"></param>
|
||
public override void openUrlBrowser(string _url)
|
||
{
|
||
SDKCall("openUrlBrowser", _url);
|
||
}
|
||
|
||
/// <summary>
|
||
/// Open ULR By WEB POP
|
||
/// </summary>
|
||
/// <param name="_url"></param>
|
||
public override void openWebUrl(string _url)
|
||
{
|
||
SDKCall("openWebUrl", _url);
|
||
}
|
||
|
||
/// <summary>
|
||
/// show Toast
|
||
/// </summary>
|
||
/// <param name="_content"></param>
|
||
public override void toast(string _content)
|
||
{
|
||
SDKCall("dialogTips", _content);
|
||
}
|
||
|
||
/// <summary>
|
||
/// push message
|
||
/// </summary>
|
||
public override void pushMsg()
|
||
{
|
||
SDKCall("pushMsg");
|
||
}
|
||
|
||
// <summary>
|
||
/// share txt
|
||
/// </summary>
|
||
/// <param name="_shareTxt"></param>
|
||
public override void ShareTxt(string _shareTxt)
|
||
{
|
||
SDKCall("localShareTxt", _shareTxt);
|
||
}
|
||
|
||
public override void RegistAPNS()
|
||
{
|
||
}
|
||
|
||
/// <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
|
||
|
||
#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)
|
||
{
|
||
SDKCall("setTkgCallback", _commonCallback);
|
||
}
|
||
|
||
public override void SetUserSourceCallback(AndroidTKGUserSourceCalllback _userSourceCallback)
|
||
{
|
||
SDKCall("getUserSource", _userSourceCallback);
|
||
}
|
||
|
||
|
||
public override void SetUserSourceCallback(AndroidTKGUserSourceCalllbackWithCampaignName _userSourceCallback)
|
||
{
|
||
SDKCall("getUserSource", _userSourceCallback);
|
||
}
|
||
|
||
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
|
||
}
|
||
}
|
||
|
||
#endif |