#if UNITY_IPHONE
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Touka
{
///
/// TKG Native SDK iOS platform interface call
///
public class TKGNativeInterfaceIOS : TKGNativeInterface
{
public override void Init(Action _initCallback = null)
{
base.Init(_initCallback);
#if !UNITY_EDITOR
TGiOSAdManager.Instance.InitSDK();
#endif
}
///
/// Get Channel
///
///
public override string GetChannel()
{
return TGiOSAdManager.Instance.getChannel().ToString();
}
///
/// Set Log Enable
///
///
public override void SetLogEnable(bool _enable)
{
TGiOSAdManager.Instance.SetLogEnable(_enable);
}
#region Ads
public override void PurchasedRemoveAds()
{
#if !UNITY_EDITOR
TGiOSAdManager.Instance.RemoveAllAds();
#endif
}
public override void SetUnitySDKVersion(string sdkVersion)
{
#if !UNITY_EDITOR
TGiOSAdManager.Instance.SetUnitySDKVersion(sdkVersion);
#endif
}
public override void RemoveNativeAd()
{
#if !UNITY_EDITOR
TGiOSAdManager.Instance.RemoveNative();
#endif
}
public override bool IsReadyNativeAd()
{
#if !UNITY_EDITOR
return TGiOSAdManager.Instance.IsReadyNative();
#else
return false;
#endif
}
public override void ShowNativeAd(RectTransform pRect, Camera pCam = null, string pAdPos = "")
{
#if !UNITY_EDITOR
TGiOSAdManager.Instance.ShowNative(pRect, pCam, pAdPos);
#endif
}
#region Ads Show
///
/// Show banner Ad
///
/// bannerAlign
public override void showBannerAd(TKGBannerAlign _pos)
{
#if !UNITY_EDITOR
TGiOSAdManager.Instance.ShowBanner((int)_pos);
#endif
}
///
/// Hide Banner Ad
///
public override void hideBannerAd()
{
#if !UNITY_EDITOR
TGiOSAdManager.Instance.HideBanner();
#endif
}
///
/// Show Interstitial Ad
///
public override void showInterstitialAd()
{
#if !UNITY_EDITOR
TGiOSAdManager.Instance.ShowIntersititial("",0);
#endif
}
///
/// Show Interstitial Ad
///
///
public override void showInterstitialAd(string _adPos, IVADType _IvType = IVADType.IV1)
{
#if !UNITY_EDITOR
TGiOSAdManager.Instance.ShowIntersititial(_adPos, (int)_IvType);
#endif
}
///
/// Show Reward Ad
///
public override void showRewardAd(string _adPos, int _itemCount = -1)
{
#if !UNITY_EDITOR
TGiOSAdManager.Instance.ShowRewardVideo(_adPos);
#endif
}
///
/// Show Reward Ad
///
///
///
///
public override void showRewardAd(string _adPos, int _itemCount, Dictionary _extraEvent)
{
#if !UNITY_EDITOR
TGiOSAdManager.Instance.ShowRewardVideo(_adPos);
#endif
}
public override void SetShowSDKToast(bool _useSDKToast)
{
#if !UNITY_EDITOR
TGiOSAdManager.Instance.ShowSDKToast(_useSDKToast);
#endif
}
///
/// Show FullScreen Ad(is RV without reward callback)
///
public override void showVideoAd(string _adPos, int _itemCount = -1)
{
#if !UNITY_EDITOR
TGiOSAdManager.Instance.ShowRewardVideo(_adPos);
#endif
}
#endregion
#region Ads isready
///
/// banner isReady
///
///
public override bool isBannerAdReady()
{
#if !UNITY_EDITOR
return TGiOSAdManager.Instance.IsReadyBanner();
#else
return false;
#endif
}
///
/// Interstitial isReady
///
///
public override bool isInterstitialAdReady()
{
#if !UNITY_EDITOR
return TGiOSAdManager.Instance.IsReadyIntersititial();
#else
return false;
#endif
}
///
/// Reward isReady
///
///
public override bool isRewardAdReady()
{
#if !UNITY_EDITOR
return TGiOSAdManager.Instance.IsReadyRewardVideo();
#else
return false;
#endif
}
///
/// FullScreen isReady
///
///
public override bool isVideoAdReady()
{
#if !UNITY_EDITOR
return TGiOSAdManager.Instance.IsReadyRewardVideo();
#else
return false;
#endif
}
#endregion
#region Set ads callback
///
/// Set Banner Ad Callback
///
///
public override void SetBannerAdCallback(AndroidBannerADTKGAdCallback _bannerCallback)
{
}
///
/// Set Interstital Ad Callback
///
///
public override void setInterstitalAdCallback(AndroidInterADTKGAdCallback _interCallback)
{
}
///
/// Set reward Ad Callback
///
///
public override void SetRewardAdCallback(AndroidRewardADTKGAdCallback _rewardCallback)
{
}
///
/// Set video Ad Callback(full screen ad, reward ad with no reward callback)
///
///
public override void setVideoAdCallback(AndroidInterADTKGAdCallback _videoCallback)
{
}
#endregion
#region load ads
///
/// load interstitial ad
/// (retry 3 times, per time interval 10s)
///
public override void loadInterstitialAD()
{
#if !UNITY_EDITOR
TGiOSAdManager.Instance.LoadIntersititial();
#endif
}
///
/// load reward ad
/// (retry 3 times, per time interval 10s)
///
public override void loadRewardAD()
{
#if !UNITY_EDITOR
TGiOSAdManager.Instance.LoadRewardVideo();
#endif
}
///
/// load video ad
/// (retry 3 times, per time interval 10s)
///
public override void loadVideoAD()
{
#if !UNITY_EDITOR
TGiOSAdManager.Instance.LoadRewardVideo();
#endif
}
#endregion
#endregion
#region Log Event
///
/// onEvent
///
///
///
public override void onEvent(string _eventName)
{
#if !UNITY_EDITOR
TGiOSAdManager.Instance.onEvent_UMeng(_eventName);
#endif
}
///
/// onEvent
///
///
///
///
///
public override void onEvent(string _eventName, string _key01, string _value01)
{
#if !UNITY_EDITOR
TGiOSAdManager.Instance.onEvent_UMeng(_eventName,_key01,_value01);
#endif
}
///
/// onEvent
///
///
///
///
///
///
///
public override void onEvent(string _eventName, string _key01, string _value01, string _key02, string _value02)
{
#if !UNITY_EDITOR
TGiOSAdManager.Instance.onEvent_UMeng(_eventName,_key01,_value01,_key02,_value02);
#endif
}
///
/// onEvent
///
///
///
public override void onEvent(string _eventName, Dictionary _keyValues)
{
#if !UNITY_EDITOR
TGiOSAdManager.Instance.onEvent_UMeng(_eventName,_keyValues);
#endif
}
#region Level Event
///
/// Level Start
///
///
public override void LevelStart(string _levelId)
{
#if !UNITY_EDITOR
TGiOSAdManager.Instance.onEvent_GameStart(_levelId);
#endif
}
///
/// Level end
///
///
public override void LevelEnd(string _levelId, StageResult _stageResult)
{
#if !UNITY_EDITOR
TGiOSAdManager.Instance.onEvent_GameEnd(_levelId,(int)_stageResult);
#endif
}
#endregion
#region Tracking Event
///
/// Log Tracking Event
///
///
public override void LogTrackingEvent(TrackingEventType _eventType)
{
#if !UNITY_EDITOR
TGiOSAdManager.Instance.onEvent_Tenjin((int)_eventType);
#endif
}
#endregion
#endregion
#region Online Config
///
/// get config - int
///
///
///
public override int GetConfigInt(string _key, int _default)
{
return TGiOSAdManager.Instance.GetConfigInt(_key, _default);
}
///
/// get config - string
///
///
///
public override string GetConfigString(string _key, string _default)
{
return TGiOSAdManager.Instance.GetConfigString(_key, _default);
}
///
/// get config - bool
///
///
///
public override bool GetConfigBool(string _key, bool _default)
{
return TGiOSAdManager.Instance.GetConfigBool(_key, _default);
}
#endregion
#region Others (Common)
///
/// review
///
public override void Review()
{
#if !UNITY_EDITOR
TGiOSAdManager.Instance.Review();
#endif
}
///
/// open Privacy
///
public override void OpenPrivacyURL()
{
#if !UNITY_EDITOR
TGiOSAdManager.Instance.OpenPrivacyURL();
#endif
}
///
/// open agreement
///
public override void OpenUserTermURL()
{
#if !UNITY_EDITOR
TGiOSAdManager.Instance.OpenUserTermURL();
#endif
}
///
/// open policy pop
///
public override void OpenPolicyPop()
{
#if !UNITY_EDITOR
TGiOSAdManager.Instance.OpenPolicyPop();
#endif
}
///
/// More Games
///
public override void OpenMoreGame()
{
#if !UNITY_EDITOR
TGiOSAdManager.Instance.OpenMoreGame();
#endif
}
//
/// share txt
///
///
public override void ShareTxt(string _shareTxt)
{
TGiOSAdManager.Instance.share(_shareTxt);
}
///
/// show picture cross
///
public override bool showPictureCross()
{
#if UNITY_EDITOR
return false;
#else
return TGiOSAdManager.Instance.showPictureCross();
#endif
}
///
/// remove picture cross
///
public override void removePictureCross()
{
#if !UNITY_EDITOR
TGiOSAdManager.Instance.removePictureCross();
#endif
}
///
/// show more game icon
///
public override bool showMoreGameIcon()
{
#if UNITY_EDITOR
return false;
#else
return TGiOSAdManager.Instance.showMoreGameIcon();
#endif
}
///
/// remove more game icon
///
public override void removeMoreGameIcon()
{
#if !UNITY_EDITOR
TGiOSAdManager.Instance.removeMoreGameIcon();
#endif
}
public override void RegistAPNS()
{
#if !UNITY_EDITOR
TGiOSAdManager.Instance.registAPNS();
#endif
}
public override void RegistNotification(string notiId, string body, string fireDate, int badge, string title, string subTitle)
{
#if !UNITY_EDITOR
TGiOSAdManager.Instance.registNotification(notiId,body,fireDate,badge,title,subTitle);
#endif
}
public override void RemoveNotification(string notiId)
{
#if !UNITY_EDITOR
TGiOSAdManager.Instance.removeNotification(notiId);
#endif
}
public override void RemoveAllNotifications()
{
#if !UNITY_EDITOR
TGiOSAdManager.Instance.removeAllNotifications();
#endif
}
#endregion
#region Others (Uncommon)
///
/// shake(no repeat)
///
/// shake time
public override void shake(int _shakeType, float _intensity = 1)
{
TGiOSAdManager.Instance.shake(_shakeType,_intensity);
}
///
/// get a iap product list for sdk config file
///
public override Dictionary GetIAPProductList()
{
return TGiOSAdManager.Instance.getIAPProductList() ;
}
///
/// set segment type to sdk
///
/// segment type
public override void SetSegment(SegmentType type)
{
TGiOSAdManager.Instance.SetSegment(type.ToString());
}
public override bool IsDebugMode()
{
return TGiOSAdManager.Instance.isDebugMode();
}
///
/// get user name and user id card
///
public override string GetUserNameAndUserIDCard()
{
return TGiOSAdManager.Instance.getUserNameAndUserIDCard();
}
///
/// shake(can repeat)
///
/// repeat times : -1
/// wait time,shake time(100,1000,100,111)
//public override void shake(int _repeatTimes, params int[] _shakeTime)
//{
//}
///
/// cancel shake
///
public override void cancelShake()
{
}
///
/// 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
///
/// title
/// content
public override void dialogTips(string _titleStr, string _contentStr)
{
}
///
/// Open ULR by Browser
///
///
public override void openUrlBrowser(string _url)
{
}
///
/// Open ULR By WEB POP
///
///
public override void openWebUrl(string _url)
{
}
///
/// show Toast
///
///
public override void toast(string _content)
{
#if !UNITY_EDITOR
TGiOSAdManager.Instance.Toast(_content);
#endif
}
///
/// push message
///
public override void pushMsg()
{
}
#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)
{
}
public override void SetUserSourceCallback(AndroidTKGUserSourceCalllback _userSourceCallback)
{
}
public override void SetUserSourceCallback(AndroidTKGUserSourceCalllbackWithCampaignName _userSourceCallback)
{
}
public override void SetFunctionSwitchCalllback(List _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 _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 AvailableLoginChannelList()
{
return TKGiOSLoginManager.Instance.AvailableLoginChannelList();
}
public override void DeleteAccount(Action _deleteAccountCallback = null)
{
TKGSDKCallback.mDeleteAccountCallback = _deleteAccountCallback;
TKGiOSLoginManager.Instance.DeleteAccount();
}
public override void BindAccount(LoginType type, BindType isForce, string userId, Action bindAccountCallback)
{
TKGSDKCallback.mBindAccountCallback = bindAccountCallback;
TKGiOSLoginManager.Instance.BindAccount(type,isForce,userId);
}
#endregion
#region IAP Event
///
/// Log IAP button show
///
/// Product name (customized on the game side) English name of the product cannot contain special characters ex: Gem100
/// Product ID: The ID of a specific product type
/// Currency ex:USD
/// Price
public override void LogIAPBtnShow(string _productName, string _productID)
{
Dictionary _keyValues = new Dictionary();
_keyValues.Add("IAP", _productName);
_keyValues.Add("ID", _productID);
//_keyValues.Add("Currency", _currency);
//_keyValues.Add("Price", _price);
onEvent("IAP_Button_Show", _keyValues);
}
///
/// Log IAP button Click
///
/// Product name (customized on the game side) English name of the product cannot contain special characters ex: Gem100
/// Product ID: The ID of a specific product type
/// Currency ex:USD
/// Price
public override void LogIAPBtnClick(string _productName, string _productID)
{
Dictionary _keyValues = new Dictionary();
_keyValues.Add("IAP", _productName);
_keyValues.Add("ID", _productID);
//_keyValues.Add("Currency", _currency);
//_keyValues.Add("Price", _price);
onEvent("IAP_Button_Click", _keyValues);
}
///
/// Log IAP First payment successful
///
/// Product name (customized on the game side) English name of the product cannot contain special characters ex: Gem100
/// Product ID: The ID of a specific product type
/// Currency ex:USD
/// Price
public override void LogIAPFirstPurchase(string _iap, string _id, string _paymentChannelOrderid, string _currency, string _price)
{
// native 层实现
//Dictionary _keyValues = new Dictionary();
//_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);
}
///
/// Log IAP payment successful
///
/// Product name (customized on the game side) English name of the product cannot contain special characters ex: Gem100
/// Product ID: The ID of a specific product type
/// The order id on the game side
/// The order id returned by the payment channel
/// Purchase token: When the purchase is successful on GP, a purchase token will be generated as a unique identifier
/// Official payment channels: appstore, googleplay, other payment channels corresponding channel name
/// Currency ex:USD
/// Price
public override void LogIAPSuccess(string _iap, string _id, string _gameOrderid, string _paymentChannelOrderid, string _productToken, string _paymentMethod, string _currency, string _price)
{
//Dictionary _keyValues = new Dictionary();
//_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 _dataCenterDict = new Dictionary();
//_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 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 callback)
{
}
public override void DetailCloudArchiving(Action callback)
{
}
public override bool IsCanAutoLogin()
{
return TKGiOSLoginManager.Instance.IsCanAutoLogin();
}
#endregion
#region serve for wz
///
/// Set userid and third account
///
/// userID (Unique user id)
/// third account
/// third account type
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
///
/// Client IAP Success
///
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
}
///
/// Client IAP Failed
///
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
}
}
#endif