2022-08-30 02:21:29 +00:00
using System ;
2022-05-23 13:39:59 +00:00
using System.Collections ;
using System.Collections.Generic ;
using UnityEngine ;
using Touka ;
2023-09-12 09:23:21 +00:00
#if USE_IAP
using UnityEngine.Purchasing ;
#endif
2022-05-23 13:39:59 +00:00
2022-08-30 02:21:29 +00:00
public class TKGSDKManager : TKGSingleton < TKGSDKManager >
2022-05-23 13:39:59 +00:00
{
2022-08-30 02:21:29 +00:00
public bool IsNoAllAD
{
get = > mIsNoAllAD ;
set
{
mIsNoAllAD = value ;
if ( mIsNoAllAD )
{
PurchasedRemoveAds ( ) ;
HideBanner ( ) ;
}
}
}
2023-09-12 09:23:21 +00:00
2022-08-30 02:21:29 +00:00
private bool mIsNoAllAD = false ;
public bool IsRemoveAds
{
get = > mIsRemoveAds ;
set
{
mIsRemoveAds = value ;
if ( mIsRemoveAds )
{
PurchasedRemoveAds ( ) ;
HideBanner ( ) ;
}
}
}
2023-09-12 09:23:21 +00:00
2022-08-30 02:21:29 +00:00
private bool mIsRemoveAds = false ;
public bool IsIAPEnabled
{
get
{
AppChannel tChannel = GetChannel ( ) ;
return ( tChannel = = AppChannel . AppStore_GB | | tChannel = = AppChannel . GooglePlay ) ;
}
}
private int mLoginCount
{
get = > PlayerPrefs . GetInt ( nameof ( mLoginCount ) , 0 ) ;
set = > PlayerPrefs . SetInt ( nameof ( mLoginCount ) , value ) ;
}
private int mPassCount
{
get = > PlayerPrefs . GetInt ( nameof ( mPassCount ) , 0 ) ;
set = > PlayerPrefs . SetInt ( nameof ( mPassCount ) , value ) ;
}
private bool mHasPoppedReview
{
get = > PlayerPrefs . GetInt ( nameof ( mHasPoppedReview ) , 0 ) = = 1 ;
set = > PlayerPrefs . SetInt ( nameof ( mHasPoppedReview ) , value ? 1 : 0 ) ;
}
private bool isInit = false ;
2022-05-23 13:39:59 +00:00
2023-09-12 09:23:21 +00:00
/// <summary>
/// 支付成功时回调
/// orderID, productName, productID, purchaseResult, gameExtra
/// </summary>
public Action < string , string , string , bool , string > OnPurchaseDone ;
2022-05-23 13:39:59 +00:00
private ITKGSDK m_sdkInterface ;
protected override void OnInstanceCreate ( )
{
base . OnInstanceCreate ( ) ;
2022-08-30 02:21:29 +00:00
2022-06-13 07:55:30 +00:00
m_sdkInterface = new TKGSDKNative ( ) ;
2022-05-23 13:39:59 +00:00
}
/// <summary>
/// init sdk
/// </summary>
/// <param name="_initCallback"></param>
public void InitSDK ( Action _initCallback = null )
{
2022-08-30 02:21:29 +00:00
if ( isInit ) return ;
2023-09-12 09:23:21 +00:00
#if USE_IAP
TKGDebugger . LogDebug ( "USE_IAP = True" ) ;
IAPTool . Instance . PreInitialize ( ) ;
#else
TKGDebugger . LogDebug ( "USE_IAP = False" ) ;
#endif
2022-05-23 13:39:59 +00:00
m_sdkInterface . InitSDK ( _initCallback ) ;
2022-08-30 02:21:29 +00:00
isInit = true ;
mLoginCount + + ;
2022-05-23 13:39:59 +00:00
2023-09-12 09:23:21 +00:00
//if (IsIAPEnabled)
//{
2022-05-23 13:39:59 +00:00
#if USE_IAP
2023-09-12 09:23:21 +00:00
IAPTool . Instance . Initialize ( ) ;
2022-05-23 13:39:59 +00:00
#endif
2023-09-12 09:23:21 +00:00
//}
2022-05-23 13:39:59 +00:00
}
/// <summary>
/// Set game focus
/// </summary>
/// <param name="_gameFocusAction"></param>
public void SetGameFocusListener ( Action < bool > _gameFocusAction )
{
m_sdkInterface . SetGameFocusListener ( _gameFocusAction ) ;
}
2022-08-30 02:21:29 +00:00
// reward click callback
public void SetRewardClickListener ( Action _clickCallback = null )
{
m_sdkInterface . SetRewardClickListener ( _clickCallback ) ;
}
2023-09-12 09:23:21 +00:00
// ads revenue callback
// adsType, price, currency
public void SetAdsRevenueCallback ( Action < AdsType , string , string > _adsRevenueCallback )
{
TKGSDKCallback . SetAdsRevenueCallback ( _adsRevenueCallback ) ;
}
2022-05-23 13:39:59 +00:00
/// <summary>
/// Get channel
/// </summary>
/// <returns></returns>
public AppChannel GetChannel ( )
{
return m_sdkInterface . GetChannel ( ) ;
}
/// <summary>
2022-08-30 02:21:29 +00:00
/// Set log enable
2022-05-23 13:39:59 +00:00
/// </summary>
2022-08-30 02:21:29 +00:00
public void SetLogEnable ( bool _enable )
2022-05-23 13:39:59 +00:00
{
2022-08-30 02:21:29 +00:00
StaticOtherConfig . IsDebugLog = _enable ;
m_sdkInterface . SetLogEnable ( _enable ) ;
2022-05-23 13:39:59 +00:00
}
2022-08-30 02:21:29 +00:00
#region Ads
2023-09-12 09:23:21 +00:00
2022-08-30 02:21:29 +00:00
// 去广告接口调用
public void PurchasedRemoveAds ( )
2022-05-23 13:39:59 +00:00
{
2022-08-30 02:21:29 +00:00
m_sdkInterface . PurchasedRemoveAds ( ) ;
2022-05-23 13:39:59 +00:00
}
2023-09-12 09:23:21 +00:00
2022-05-23 13:39:59 +00:00
/// <summary>
2022-08-30 02:21:29 +00:00
/// Show Interstitial Ad
2022-05-23 13:39:59 +00:00
/// </summary>
2022-08-30 02:21:29 +00:00
/// <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 )
2023-09-12 09:23:21 +00:00
{
ShowInterstitialAd ( _adPos . ToString ( ) , _callback , _IvType ) ;
}
public void ShowInterstitialAd ( string _adPos , Action _callback = null , IVADType _IvType = IVADType . IV1 )
2022-05-23 13:39:59 +00:00
{
2022-08-30 02:21:29 +00:00
#if UNITY_EDITOR | | NO_AD
2022-05-23 13:39:59 +00:00
if ( null ! = _callback )
{
2022-08-30 02:21:29 +00:00
Debug . Log ( "Need Show IV, in editor directly invoke callback." ) ;
2022-05-23 13:39:59 +00:00
_callback . Invoke ( ) ;
}
2023-09-12 09:23:21 +00:00
2022-08-30 02:21:29 +00:00
return ;
2022-05-23 13:39:59 +00:00
#endif
2022-08-30 02:21:29 +00:00
if ( IsNoAllAD | | IsRemoveAds )
2022-05-23 13:39:59 +00:00
{
_callback ? . Invoke ( ) ;
}
else
{
2022-08-30 02:21:29 +00:00
m_sdkInterface . ShowInterstitialAd ( _adPos , _callback , _IvType ) ;
2022-05-23 13:39:59 +00:00
}
}
/// <summary>
2022-08-30 02:21:29 +00:00
/// Show Reward Ad
2022-05-23 13:39:59 +00:00
/// </summary>
2022-08-30 02:21:29 +00:00
/// <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>
2023-09-12 09:23:21 +00:00
public void ShowRewardAd ( TKGRVPositionName _adPos , Action < bool > _rewardCallback = null ,
Action _showFailedCallback = null , bool showSDKToast = false )
{
ShowRewardAd ( _adPos . ToString ( ) , _rewardCallback , _showFailedCallback , showSDKToast ) ;
}
public void ShowRewardAd ( string _adPos , Action < bool > _rewardCallback = null , Action _showFailedCallback = null ,
bool showSDKToast = false )
2022-05-23 13:39:59 +00:00
{
2022-08-30 02:21:29 +00:00
#if UNITY_EDITOR | | NO_AD
if ( null ! = _rewardCallback )
2022-05-23 13:39:59 +00:00
{
_rewardCallback . Invoke ( true ) ;
}
2023-09-12 09:23:21 +00:00
2022-05-23 13:39:59 +00:00
return ;
#endif
if ( IsNoAllAD )
{
_rewardCallback ? . Invoke ( true ) ;
}
else
{
2022-08-30 05:43:52 +00:00
m_sdkInterface . SetShowSDKToast ( showSDKToast ) ;
2022-08-30 02:21:29 +00:00
m_sdkInterface . ShowRewardAd ( _adPos , _rewardCallback , _showFailedCallback ) ;
2022-05-23 13:39:59 +00:00
}
}
2022-08-30 02:21:29 +00:00
public void ShowNative ( RectTransform pRect , Camera pCam = null , string pAdPos = "" )
{
#if ! NO_AD
if ( ! IsNoAllAD & & ! IsRemoveAds )
{
m_sdkInterface . ShowNativeAd ( pRect , pCam , pAdPos ) ;
2023-09-12 09:23:21 +00:00
}
2022-08-30 02:21:29 +00:00
#endif
}
2022-05-23 13:39:59 +00:00
/// <summary>
/// Is Ready Interstitial
/// </summary>
/// <returns></returns>
public bool IsReadyInterstitialAd ( )
{
return m_sdkInterface . IsReadyInterstitialAd ( ) ;
}
/// <summary>
/// Is Ready Reward
/// </summary>
/// <returns></returns>
public bool IsReadyRewardAd ( )
{
return m_sdkInterface . IsReadyRewardAd ( ) ;
}
2022-08-30 02:21:29 +00:00
/// <summary>
/// Is Ready Native Ad
/// </summary>
/// <returns></returns>
public bool IsReadyNativeAd ( )
{
#if NO_AD
return false ;
#else
return m_sdkInterface . IsReadyNativeAd ( ) ;
#endif
}
/// <summary>
/// Show banner
/// </summary>
/// <param name="_bannerAlign">bannerAlign</param>
public void ShowBanner ( TKGBannerAlign _bannerAlign )
{
#if ! NO_AD
if ( ! IsNoAllAD & & ! IsRemoveAds )
{
m_sdkInterface . ShowBanner ( _bannerAlign ) ;
}
#endif
}
/// <summary>
/// Hide banner
/// </summary>
public void HideBanner ( )
{
m_sdkInterface . HideBanner ( ) ;
}
/// <summary>
/// Remove Native
/// </summary>
public void RemoveNative ( )
{
m_sdkInterface . RemoveNativeAd ( ) ;
}
2023-09-12 09:23:21 +00:00
#endregion
2022-05-23 13:39:59 +00:00
2023-09-12 09:23:21 +00:00
#region Log Event
2022-05-23 13:39:59 +00:00
2023-09-12 09:23:21 +00:00
#region Normal
2022-05-23 13:39:59 +00:00
/// <summary>
/// Log Event
/// </summary>
/// <param name="_eventSort"></param>
public void LogEvent ( string _eventSort )
{
m_sdkInterface . LogEvent ( _eventSort ) ;
}
/// <summary>
/// Log Event
/// </summary>
/// <param name="_eventSort"></param>
/// <param name="_key"></param>
/// <param name="_value"></param>
public void LogEvent ( string _eventSort , string _key , string _value )
{
m_sdkInterface . LogEvent ( _eventSort , _key , _value ) ;
}
/// <summary>
/// Log Event
/// </summary>
/// <param name="_eventSort"></param>
/// <param name="_key01"></param>
/// <param name="_value01"></param>
/// <param name="_key02"></param>
/// <param name="_value02"></param>
public void LogEvent ( string _eventSort , string _key01 , string _value01 , string _key02 , string _value02 )
{
m_sdkInterface . LogEvent ( _eventSort , _key01 , _value01 , _key02 , _value02 ) ;
}
/// <summary>
/// Log Event
/// </summary>
/// <param name="_eventSort"></param>
/// <param name="_eventDic"></param>
public void LogEvent ( string _eventSort , Dictionary < string , string > _eventDic = null )
{
m_sdkInterface . LogEvent ( _eventSort , _eventDic ) ;
}
2023-09-12 09:23:21 +00:00
#endregion
2022-05-23 13:39:59 +00:00
2023-09-12 09:23:21 +00:00
#region Level Event
2022-05-23 13:39:59 +00:00
/// <summary>
2022-08-30 02:21:29 +00:00
/// Level start
2022-05-23 13:39:59 +00:00
/// </summary>
/// <param name="_level"></param>
2022-08-30 02:21:29 +00:00
public void LevelStart ( int _level )
2022-05-23 13:39:59 +00:00
{
2022-08-30 02:21:29 +00:00
LevelStart ( _level . ToString ( ) ) ;
2022-05-23 13:39:59 +00:00
}
/// <summary>
2022-08-30 02:21:29 +00:00
/// Level start
2022-05-23 13:39:59 +00:00
/// </summary>
/// <param name="_level"></param>
2022-08-30 02:21:29 +00:00
public void LevelStart ( string _level )
2022-05-23 13:39:59 +00:00
{
2022-08-30 02:21:29 +00:00
m_sdkInterface . LevelStart ( _level ) ;
2022-05-23 13:39:59 +00:00
}
/// <summary>
2022-08-30 02:21:29 +00:00
/// Level end
2022-05-23 13:39:59 +00:00
/// </summary>
/// <param name="_level"></param>
/// <param name="_win"></param>
2022-08-30 02:21:29 +00:00
public bool LevelEnd ( int _level , StageResult _stageResult )
2022-05-23 13:39:59 +00:00
{
2022-08-30 02:21:29 +00:00
return LevelEnd ( _level . ToString ( ) , _stageResult ) ;
2022-05-23 13:39:59 +00:00
}
/// <summary>
2022-08-30 02:21:29 +00:00
/// Level end,if return false, it means review pops up.
2022-05-23 13:39:59 +00:00
/// </summary>
/// <param name="_level"></param>
/// <param name="_win"></param>
2022-08-30 02:21:29 +00:00
public bool LevelEnd ( string _level , StageResult _stageResult )
2022-05-23 13:39:59 +00:00
{
2022-08-30 02:21:29 +00:00
m_sdkInterface . LevelEnd ( _level , _stageResult ) ;
if ( _stageResult = = StageResult . StageSucc )
{
mPassCount + + ;
2023-09-12 09:23:21 +00:00
#if UNITY_IOS //only ios has review popup
2022-08-30 02:21:29 +00:00
return ! CheckReviewPop ( mPassCount ) ;
#endif
}
return true ;
2022-05-23 13:39:59 +00:00
}
2022-08-30 02:21:29 +00:00
private bool CheckReviewPop ( int pLevel )
{
if ( mHasPoppedReview )
return false ;
if ( mLoginCount = = 1 & & pLevel = = StaticOtherConfig . FirstLoginPopLevel )
{
Debug . Log ( "pop first review" ) ;
mHasPoppedReview = true ;
Review ( ) ;
return true ;
}
else if ( mLoginCount > 1 & & pLevel = = StaticOtherConfig . OtherLoginPopLevel )
{
Debug . Log ( "pop other review" ) ;
mHasPoppedReview = true ;
Review ( ) ;
return true ;
}
return false ;
}
2022-05-23 13:39:59 +00:00
2023-09-12 09:23:21 +00:00
#endregion
#region Reward Ad Button Show
2022-05-23 13:39:59 +00:00
/// <summary>
/// Log Reward ad button show
/// </summary>
/// <param name="_pos"></param>
public void LogRewardAdBtnShow ( string _pos )
{
m_sdkInterface . LogRewardAdBtnShow ( _pos ) ;
}
2023-09-12 09:23:21 +00:00
#endregion
2022-05-23 13:39:59 +00:00
2023-09-12 09:23:21 +00:00
#region Tracking Event
2022-05-23 13:39:59 +00:00
/// <summary>
/// Log Tracking Event
/// </summary>
/// <param name="_eventType"></param>
2022-08-30 02:21:29 +00:00
private void LogTrackingEvent ( TrackingEventType _eventType )
2022-05-23 13:39:59 +00:00
{
2022-08-30 02:21:29 +00:00
//m_sdkInterface.LogTrackingEvent(_eventType);
2022-05-23 13:39:59 +00:00
}
2023-09-12 09:23:21 +00:00
#endregion
2022-05-23 13:39:59 +00:00
2023-09-12 09:23:21 +00:00
#endregion
2022-05-23 13:39:59 +00:00
2023-09-12 09:23:21 +00:00
#region Online Config
2022-05-23 13:39:59 +00:00
/// <summary>
/// get config - string
/// </summary>
/// <param name="_key"></param>
/// <returns></returns>
2023-09-12 09:23:21 +00:00
public string GetConfigStr ( string _key )
2022-05-23 13:39:59 +00:00
{
2023-09-12 09:23:21 +00:00
return m_sdkInterface . GetConfigStr ( _key ) ;
}
2022-05-23 13:39:59 +00:00
2023-09-12 09:23:21 +00:00
public string GetConfigStr ( TKGParamKey _key )
{
2022-08-30 02:21:29 +00:00
return m_sdkInterface . GetConfigStr ( _key . ToString ( ) ) ;
2022-05-23 13:39:59 +00:00
}
/// <summary>
/// get config - int
/// </summary>
/// <param name="_key"></param>
/// <returns></returns>
2023-09-12 09:23:21 +00:00
public int GetConfigInt ( string _key )
2022-05-23 13:39:59 +00:00
{
2023-09-12 09:23:21 +00:00
return m_sdkInterface . GetConfigInt ( _key ) ;
}
2022-05-23 13:39:59 +00:00
2023-09-12 09:23:21 +00:00
public int GetConfigInt ( TKGParamKey _key )
{
2022-08-30 02:21:29 +00:00
return m_sdkInterface . GetConfigInt ( _key . ToString ( ) ) ;
2022-05-23 13:39:59 +00:00
}
2022-08-30 02:21:29 +00:00
2022-05-23 13:39:59 +00:00
/// <summary>
/// get config - bool
/// </summary>
/// <param name="_key"></param>
/// <returns></returns>
2023-09-12 09:23:21 +00:00
public bool GetConfigBool ( string _key )
{
return m_sdkInterface . GetConfigBool ( _key ) ;
}
2022-08-30 02:21:29 +00:00
public bool GetConfigBool ( TKGParamKey _key )
2022-05-23 13:39:59 +00:00
{
2022-08-30 02:21:29 +00:00
return m_sdkInterface . GetConfigBool ( _key . ToString ( ) ) ;
2022-05-23 13:39:59 +00:00
}
2023-09-12 09:23:21 +00:00
#endregion
2022-05-23 13:39:59 +00:00
2023-09-12 09:23:21 +00:00
#region Others ( common )
2022-05-23 13:39:59 +00:00
/// <summary>
/// review
/// </summary>
public void Review ( )
{
m_sdkInterface . Review ( ) ;
}
2022-08-30 02:21:29 +00:00
/// 使用 OpenPolicyPop 接口 === Use OpenPolicyPop
/// 使用 OpenPolicyPop 接口 === Use OpenPolicyPop
/// 使用 OpenPolicyPop 接口 === Use OpenPolicyPop
2022-05-23 13:39:59 +00:00
/// <summary>
/// open privacy url
/// </summary>
2022-08-30 02:21:29 +00:00
//public void OpenPrivacyURL()
//{
// m_sdkInterface.OpenPrivacyURL();
//}
/// 使用 OpenPolicyPop 接口 === Use OpenPolicyPop
/// 使用 OpenPolicyPop 接口 === Use OpenPolicyPop
/// 使用 OpenPolicyPop 接口 === Use OpenPolicyPop
2022-05-23 13:39:59 +00:00
/// <summary>
/// open user agreement url
/// </summary>
2022-08-30 02:21:29 +00:00
//public void OpenUserTermURL()
//{
// m_sdkInterface.OpenUserTermURL();
//}
2022-05-23 13:39:59 +00:00
/// <summary>
/// open more game
/// </summary>
public void OpenMoreGame ( )
{
m_sdkInterface . OpenMoreGame ( ) ;
}
2023-09-12 09:23:21 +00:00
/// <summary>
/// show picture cross
/// </summary>
public bool showPictureCross ( )
{
return m_sdkInterface . showPictureCross ( ) ;
}
/// <summary>
/// remove picture cross
/// </summary>
public void removePictureCross ( )
{
m_sdkInterface . removePictureCross ( ) ;
}
/// <summary>
/// show more game icon
/// </summary>
public bool showMoreGameIcon ( )
{
return m_sdkInterface . showMoreGameIcon ( ) ;
}
/// <summary>
/// remove more game icon
/// </summary>
public void removeMoreGameIcon ( )
{
m_sdkInterface . removeMoreGameIcon ( ) ;
}
2022-05-23 13:39:59 +00:00
/// <summary>
/// open url by browser
/// </summary>
/// <param name="_url"></param>
public void OpenUrlByBrowser ( string _url )
{
m_sdkInterface . OpenUrlByBrowser ( _url ) ;
}
2022-08-30 02:21:29 +00:00
public void OpenPolicyPop ( )
{
m_sdkInterface . OpenPolicyPop ( ) ;
}
2022-05-23 13:39:59 +00:00
/// <summary>
/// shake
/// </summary>
/// <param name="_shakeType">0 light,1 medium,2 heavy</param>
/// <param name="_intensity">ios 0~1, android any num</param>
public void Shake ( int _shakeType , float _intensity = 1 )
{
m_sdkInterface . Shake ( _shakeType , _intensity ) ;
}
2022-08-30 02:21:29 +00:00
2023-09-12 09:23:21 +00:00
/// <summary>
/// if is debug mode
/// </summary>
public bool IsDebugMode ( )
{
return m_sdkInterface . IsDebugMode ( ) ;
}
/// <summary>
/// get user name and user id card
/// format will be "Jack_654121199212099999"
/// </summary>
public string GetUserNameAndUserIDCard ( )
{
return m_sdkInterface . GetUserNameAndUserIDCard ( ) ;
}
/// <summary>
/// set segment type to sdk
/// </summary>
/// <param name="type">segment type</param>
public void SetSegment ( SegmentType type )
{
m_sdkInterface . SetSegment ( type ) ;
}
/// <summary>
/// get a iap product list for sdk config file
/// </summary>
public Dictionary < string , string > GetIAPProductList ( )
{
return m_sdkInterface . GetIAPProductList ( ) ;
}
2022-08-30 05:43:52 +00:00
/// <summary>
/// share txt
/// </summary>
/// <param name="_shareTxt"></param>
public void Share ( string shareText )
{
m_sdkInterface . ShareTxt ( shareText ) ;
}
/// <summary>
/// regist APNS
/// </summary>
public void RegistAPNS ( )
{
m_sdkInterface . RegistAPNS ( ) ;
}
/// <summary>
/// shake
/// </summary>
/// <param name="notiName">notification identifier</param>
/// <param name="body">The body of the notification.</param>
/// <param name="fireDate">notify after the time interval. format:yyyy-MM-dd HH:mm:ss </param>
/// <param name="badge">The application badge number.</param>
/// <param name="title">The title of the notification.</param>
/// <param name="subTitle">The subtitle of the notification.</param>
2023-09-12 09:23:21 +00:00
public void RegistNotification ( string notiId , string body , string fireDate , int badge = 1 , string title = "" ,
string subTitle = "" )
2022-08-30 05:43:52 +00:00
{
2023-09-12 09:23:21 +00:00
m_sdkInterface . RegistNotification ( notiId , body , fireDate , badge , title , subTitle ) ;
2022-08-30 05:43:52 +00:00
}
/// <summary>
/// remove all notification
/// </summary>
public void RemoveAllNotifications ( )
{
m_sdkInterface . RemoveAllNotifications ( ) ;
}
/// <summary>
/// remove notification by notification identifier
/// </summary>
/// <param name="notiId">notification identifier</param>
public void RemoveNotification ( string notiId )
{
m_sdkInterface . RemoveNotification ( notiId ) ;
}
2023-09-12 09:23:21 +00:00
2022-08-30 05:43:52 +00:00
#endregion
#region others
public void Toast ( string text )
{
m_sdkInterface . Toast ( text ) ;
}
2022-08-30 02:21:29 +00:00
/// <summary>
/// Set user source listener
/// only call first can back source
/// </summary>
2022-08-30 05:43:52 +00:00
/// <param name="_userSourceAction"> true : origin user, false : not origin user </param>2
2022-08-30 02:21:29 +00:00
public void SetUserSourceListener ( Action < bool , string > _userSourceAction )
{
m_sdkInterface . SetUserSourceListener ( _userSourceAction ) ;
}
2022-08-30 05:43:52 +00:00
/// <summary>
/// Set user source listener
/// only call first can back source
/// with campaginName
/// </summary>
/// <param name="_userSourceAction"> true : origin user, false : not origin user </param>2
public void SetUserSourceListener ( Action < bool , string , string > _userSourceAction )
{
m_sdkInterface . SetUserSourceListener ( _userSourceAction ) ;
}
2022-08-30 02:21:29 +00:00
/// <summary>
/// set common callback
/// </summary>
/// <param name="_commonCallbackAction"></param>
public void SetTKGCommonCallback ( Action < CommonCallbackCode , string > _commonCallbackAction )
{
m_sdkInterface . SetTKGCommonCallback ( _commonCallbackAction ) ;
}
2023-09-12 09:23:21 +00:00
/// <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
#region 数 据 中 台
/// <summary>
/// 内购成功后上报价格
/// </summary>
/// <param name="price"> 商品价格 </param>
public void LogPurchasePrice ( string price , string currency )
{
m_sdkInterface . LogPurchasePrice ( price , currency ) ;
}
/// <summary>
/// Robux点击提现按钮
/// </summary>
public void LogRobuxCashOut ( )
{
m_sdkInterface . LogRobuxCashOut ( ) ;
}
/// <summary>
/// 完成新手引导
/// </summary>
public void LogNoviceGuideFinish ( )
{
m_sdkInterface . LogNoviceGuideFinish ( ) ;
}
#endregion
#region GooglePlay评论引导
/// <summary>
/// Pop up GooglePlay Rate guid
/// </summary>
public bool GuidGpComment ( )
{
return m_sdkInterface . GuidGpComment ( ) ;
}
#endregion
#region 用 户 登 录
/// <summary>
/// User Login
/// </summary>
/// <param name="_loginType">登录类型</param>
/// <param name="_loginResultCallback">登录回调Action<登录状态码, 登录类型, 登录状态信息, userid, token, 邮箱 , 显示名称 , 头像url</param>
public void Login ( LoginType _loginType ,
Action < LoginStatus , LoginType , string , string , string , string , string , string > _loginResultCallback = null )
{
m_sdkInterface . Login ( _loginType , _loginResultCallback ) ;
}
/// <summary>
/// 自动根据上次登陆的类型进行登陆,登陆失败需要跳转到登陆界面。
/// </summary>
/// <param name="_loginResultCallback"></param>
public void AutoLogin (
Action < LoginStatus , LoginType , string , string , string , string , string , string > _loginResultCallback = null )
{
m_sdkInterface . AutoLogin ( _loginResultCallback ) ;
}
/// <summary>
/// 获取当前账号类型。 用于显示绑定界面。
/// </summary>
/// <returns></returns>
public LoginType GetAccountType ( )
{
return m_sdkInterface . GetAccountType ( ) ;
}
/// <summary>
/// 是否可以自动登陆
/// </summary>
/// <returns></returns>
public bool IsCanAutoLogin ( )
{
return m_sdkInterface . IsCanAutoLogin ( ) ;
}
/// <summary>
/// Logout
/// </summary>
/// <param name="_logoutCallback"></param>
public void Logout ( Action _logoutCallback = null )
{
m_sdkInterface . Logout ( _logoutCallback ) ;
}
/// <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>
public List < LoginType > AvailableLoginChannelList ( )
{
return m_sdkInterface . 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">code Delete userId</param>
public void DeleteAccount ( Action < DeleteStatus , string > deleteAccountCallback = null )
{
m_sdkInterface . DeleteAccount ( deleteAccountCallback ) ;
}
/// <summary>
/// Social account binding for Guester.
/// 游客绑定社交账号
///
/// 游戏发起社交账号的绑定:
/// 根据 Action中的BindAccountStatus判断
/// 如果 BindAccountStatus == BindAccountStatus.BIND_CODE_SUCC
/// 需要判断userId和当前userId是否一致, 如果不一致, 需要切换账号, 或者重启游戏。如果一致, 无需操作。
/// 如果 BindAccountStatus == BindAccountStatus.BIND_CODE_SELECT
/// 这个是因为第三方账号已经被绑定过了, string[] 中将会返回已经绑定的userId, 和当前userId, 游戏需要展示出来提供给玩家选择,
/// 玩家选择完成后,需要将
///
/// 其情况,游戏做相应操作
///
///
///
/// </summary>
/// <param name="type">社交账号类型</param>
/// <param name="isForce">是否强制绑定</param>
/// <param name="userId">绑定的userId</param>
/// <param name="bindAccountCallback">回调的信息</param>
private void BindAccount ( LoginType type , BindType isForce = BindType . NO_FORCE , string userId =
{
m_sdkInterface . BindAccount ( type , isForce , userId , bindAccountCallback ) ;
}
private LoginType bindLoginType = LoginType . LOGIN_BY_GUESTER ;
/// <summary>
/// Social account binding for Guester.
///
/// 情况一 : bindAccountStatusEnum == BindAccountStatus.BIND_CODE_SUCC 绑定成功
/// 绑定成功的时候,需要获取 userId和当前userId是否一致, 如果不一致, 需要重新切换到新的userId账号上来。 (切换账号)
/// 情况二 : BindAccountStatus == BindAccountStatus.BIND_CODE_SELECT 社交账号已经绑定了其他账号 (社交账号已经在其他设备上登陆)
/// 需要获取到userIdList 里面的userId列表, 获取到userId对应的角色/关卡信息,展示出来供玩家选择。 玩家选择完成之后调用 `ForceBindAccount` 接口将选中的userId传递进去, 进行强制绑定
/// ⚠️ 如果选择的是当前账号强制绑定,那么社交账号原有的账号将会被删除
/// 如果选择的是社交账号关联的账号,那么当前账号将会被删除
///
///
/// </summary>
/// <param name="type">社交账号类型</param>
/// <param name="bindAccountCallback">bindAccountStatusEnum, loginTypeEnum, _msg, _userId, _token, _email,_displayName, _photoUrl, userIdList</param>
public void BindAccount ( LoginType type ,
Action < BindAccountStatus , LoginType , string , string , string , string , string , string , string [ ] >
bindAccountCallback = null )
{
bindLoginType = type ;
BindAccount ( type , isForce : BindType . NO_FORCE , userId : "" , bindAccountCallback ) ;
}
public void ForceBindAccount ( string userId , Action < BindAccountStatus , LoginType , string , string , string , string , string , string , string [ ] >
bindAccountCallback = null )
{
BindAccount ( bindLoginType , BindType . FORCE , userId , bindAccountCallback ) ;
}
#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 void LogIAPBtnShow ( string productName , string productId )
{
m_sdkInterface . LogIAPBtnShow ( productName , productId ) ;
}
#endregion
#region 保 存 数 据
/// <summary>
/// 保存数据到账号上去(云存储)
/// </summary>
/// <param name="content">string内容存储</param>
/// <param name="callback">上传结果</param>
public void SaveCloudArchiving ( string content , Action < int , string > callback )
{
m_sdkInterface . SaveCloudArchiving ( content , callback ) ;
}
/// <summary>
/// 获取云存储的当前账号数据
/// </summary>
/// <returns></returns>
public void DetailCloudArchiving ( Action < int , string > callback )
{
m_sdkInterface . DetailCloudArchiving ( callback ) ;
}
#endregion
#region IAP
/// <summary>
/// Add payment result callback;
/// orderID, productName, productID, purchaseResult, gameExtra
/// </summary>
/// <param name="onPurchaseDoneAction">Purchase result callback<OrderID,Product ID,pay result, game extra></param>
public void SetOnPurchaseDone ( Action < string , string , string , bool , string > onPurchaseDoneAction )
{
OnPurchaseDone = onPurchaseDoneAction ;
}
#if USE_IAP
/// <summary>
/// Commodity information acquisition callback;
/// </summary>
/// <param name="onGetProductsInfo">All product information</param>
/// ex:
/// Product[0].metadata.localizedTitle
/// Product[0].metadata.localizedPriceString
/// Product[0].metadata.localizedDescription
/// Product[0].metadata.isoCurrencyCode
public void OnGetProductsInfo ( Action < Product [ ] > onGetProductsInfo )
{
#if USE_IAP
IAPTool . Instance . OnGetProductsInfo + = onGetProductsInfo ;
#endif
}
/// <summary>
/// Get product info by product id;
/// </summary>
/// <param name="productID">Product ID</param>
/// <returns>Product Info metadata</returns>
public Product GetProductInfoByID ( string productID )
{
#if USE_IAP
return IAPTool . Instance . GetProductInfoByID ( productID ) ;
#else
return null ;
#endif
}
#endif
/// <summary>
/// Get product price by product id;
/// </summary>
/// <param name="productID">Product ID</param>
/// <returns>Product price</returns>
public string GetPriceByID ( string productID )
{
#if USE_IAP
return IAPTool . Instance . GetPriceByID ( productID ) ;
#else
return "" ;
#endif
}
#if USE_IAP
/// <summary>
///[In-game props,gold,gift packs, etc.] Purchase products according to the product ID;
/// </summary>
/// <param name="productId">Product ID </param>
/// <param name="enProductName">Product ID </param>
/// <param name="onPurchaseDoneAction">Purchase result callback<Product ID,pay result, order id, token></param>
/// <param name="gameExtraParam">Product ID </param>
public void BuyProductByID ( string productId , string enProductName , string gameExtraParam = "" )
{
#if USE_IAP
IAPTool . Instance . BuyProductByID ( productId , enProductName , gameExtraParam ) ;
#endif
}
#endif
#if USE_IAP
/// <summary>
/// Add products ID dynamically;
/// </summary>
/// <param name="products">Product IDs</param>
/// <param name="onProductsResult">bool Is it added successfully string Additional Information</param>
public void AddProducts ( Dictionary < string , ProductType > products )
{
#if USE_IAP
IAPTool . Instance . AddProducts ( products ) ;
#endif
}
#endif
/// <summary>
/// Restore Purchases;
/// </summary>
public void RestorePurchases ( )
{
#if USE_IAP
IAPTool . Instance . RestorePurchases ( ) ;
#endif
}
#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 void SetUserIDAndThirdAccount ( string _userID , string _thirdAccount , ThirdAccountType _thirdAccountType )
{
Debug . Log ( "【TKGNativeInterfaceAndroid】 SetUserIDAndThirdAccount _userID : " + _userID + " , _thirdAccount : " + _thirdAccount + " , _thirdAccountType : " + _thirdAccountType ) ;
TKGNativeInterface . Instance . SetUserIDAndThirdAccount ( _userID , _thirdAccount , _thirdAccountType ) ;
}
2022-08-30 02:21:29 +00:00
#endregion
2023-09-12 09:23:21 +00:00
}