添加实现基类;添加IAP接口调用
parent
97b9a6cc5a
commit
88576c3231
|
|
@ -2,11 +2,11 @@ using System;
|
|||
using Guru;
|
||||
using UnityEngine;
|
||||
|
||||
namespace GuruSDKService
|
||||
namespace GuruService
|
||||
{
|
||||
public partial class GuruSDKService
|
||||
public static partial class GuruSDKService
|
||||
{
|
||||
private void AddCallbackListener()
|
||||
private static void AddCallbackListener()
|
||||
{
|
||||
GuruSDK.Callbacks.App.OnAppPaused += OnAppPaused;
|
||||
GuruSDK.Callbacks.App.OnAppQuit += OnAppQuit;
|
||||
|
|
@ -31,13 +31,13 @@ namespace GuruSDKService
|
|||
|
||||
#region App Callbacks
|
||||
|
||||
private void OnAppPaused(bool paused)
|
||||
private static void OnAppPaused(bool paused)
|
||||
{
|
||||
Log.I($"[GuruCallback][OnAppPaused] paused:{paused}");
|
||||
_serviceImp?.OnAppPaused(paused);
|
||||
}
|
||||
|
||||
private void OnAppQuit()
|
||||
private static void OnAppQuit()
|
||||
{
|
||||
Log.I($"[GuruCallback][OnAppQuit]");
|
||||
_serviceImp?.OnAppQuit();
|
||||
|
|
@ -47,28 +47,28 @@ namespace GuruSDKService
|
|||
|
||||
#region SDK Callbacks
|
||||
|
||||
private Action _onFirebaseReady;
|
||||
private static Action _onFirebaseReady;
|
||||
|
||||
private void OnFirebaseReady(bool success)
|
||||
private static void OnFirebaseReady(bool success)
|
||||
{
|
||||
Log.I($"[GuruCallback][OnFirebaseReady] success:{success}");
|
||||
if (success) _onFirebaseReady?.Invoke();
|
||||
_serviceImp?.OnFirebaseReady(success);
|
||||
}
|
||||
|
||||
private void OnGuruServiceReady()
|
||||
private static void OnGuruServiceReady()
|
||||
{
|
||||
Log.I($"[GuruCallback][OnGuruServiceReady]");
|
||||
_serviceImp?.OnGuruServiceReady();
|
||||
}
|
||||
|
||||
private void OnUserAuthResult(bool success)
|
||||
private static void OnUserAuthResult(bool success)
|
||||
{
|
||||
Log.I($"[GuruCallback][OnUserAuthResult] success:{success}");
|
||||
_serviceImp?.OnUserAuthResult(success);
|
||||
}
|
||||
|
||||
private void OnFirebaseAuthResult(bool success)
|
||||
private static void OnFirebaseAuthResult(bool success)
|
||||
{
|
||||
Log.I($"[GuruCallback][OnFirebaseAuthResult] success:{success}");
|
||||
_serviceImp?.OnFirebaseAuthResult(success);
|
||||
|
|
@ -78,13 +78,13 @@ namespace GuruSDKService
|
|||
|
||||
#region ConsentFlow Callbacks
|
||||
|
||||
private void OnAttResult(int authorizationTrackingStatus)
|
||||
private static void OnAttResult(int authorizationTrackingStatus)
|
||||
{
|
||||
Log.I($"[GuruCallback][OnAttResult] authorizationTrackingStatus:{authorizationTrackingStatus}");
|
||||
_serviceImp?.OnAttResult(authorizationTrackingStatus);
|
||||
}
|
||||
|
||||
private void OnConsentResult(int statusCode)
|
||||
private static void OnConsentResult(int statusCode)
|
||||
{
|
||||
Log.I($"[GuruCallback][OnConsentResult] statusCode:{statusCode}");
|
||||
_serviceImp?.OnConsentResult(statusCode);
|
||||
|
|
@ -94,15 +94,15 @@ namespace GuruSDKService
|
|||
|
||||
#region AD Callbacks
|
||||
|
||||
private void OnAdsInitComplete()
|
||||
private static void OnAdsInitComplete()
|
||||
{
|
||||
Log.I($"[GuruCallback][OnAdsInitComplete]");
|
||||
_serviceImp?.OnAdsInitComplete();
|
||||
}
|
||||
|
||||
public bool HasBannerADLoaded;
|
||||
public static bool HasBannerADLoaded;
|
||||
|
||||
private void OnBannerADLoaded()
|
||||
private static void OnBannerADLoaded()
|
||||
{
|
||||
Log.I($"[GuruCallback][OnBannerADLoaded]");
|
||||
GuruSDK.Callbacks.Ads.OnBannerADLoaded -= OnBannerADLoaded; //只监听第一次banner加载成功,处理banner显示逻辑
|
||||
|
|
@ -110,25 +110,25 @@ namespace GuruSDKService
|
|||
_serviceImp?.OnBannerADLoaded();
|
||||
}
|
||||
|
||||
private void OnInterstitialADLoaded()
|
||||
private static void OnInterstitialADLoaded()
|
||||
{
|
||||
Log.I($"[GuruCallback][OnInterstitialADLoaded]");
|
||||
_serviceImp?.OnInterstitialADLoaded();
|
||||
}
|
||||
|
||||
private void OnInterstitialADFailed()
|
||||
private static void OnInterstitialADFailed()
|
||||
{
|
||||
Log.I($"[GuruCallback][OnInterstitialADFailed]");
|
||||
_serviceImp?.OnInterstitialADFailed();
|
||||
}
|
||||
|
||||
private void OnRewardedADLoaded()
|
||||
private static void OnRewardedADLoaded()
|
||||
{
|
||||
Log.I($"[GuruCallback][OnRewardedADLoaded]");
|
||||
_serviceImp?.OnRewardedADLoaded();
|
||||
}
|
||||
|
||||
private void OnRewardADFailed()
|
||||
private static void OnRewardADFailed()
|
||||
{
|
||||
Log.I($"[GuruCallback][OnRewardADFailed]");
|
||||
_serviceImp?.OnRewardADFailed();
|
||||
|
|
@ -138,9 +138,9 @@ namespace GuruSDKService
|
|||
|
||||
#region Firebase Component Callbacks
|
||||
|
||||
public bool IsRemoteConfigFetchSuccess = false;
|
||||
public static bool IsRemoteConfigFetchSuccess = false;
|
||||
|
||||
private void OnRemoteFetchComplete(bool success)
|
||||
private static void OnRemoteFetchComplete(bool success)
|
||||
{
|
||||
Log.I($"[GuruCallback][OnRemoteFetchComplete] success:{success}");
|
||||
IsRemoteConfigFetchSuccess = success;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
using Guru;
|
||||
using UnityEngine.Purchasing;
|
||||
|
||||
namespace GuruSDKService
|
||||
namespace GuruService
|
||||
{
|
||||
public partial class GuruSDKService
|
||||
{
|
||||
private void AddIAPCallbackListener()
|
||||
private static void AddIAPCallbackListener()
|
||||
{
|
||||
GuruSDK.Callbacks.IAP.OnIAPInitStart += OnIAPInitStart;
|
||||
GuruSDK.Callbacks.IAP.OnIAPInitComplete += OnIAPInitComplete;
|
||||
|
|
@ -17,41 +17,49 @@ namespace GuruSDKService
|
|||
|
||||
#region callbacks
|
||||
|
||||
private void OnIAPInitStart()
|
||||
private static void OnIAPInitStart()
|
||||
{
|
||||
Log.I($"[GuruCallback][OnIAPInitStart]");
|
||||
_serviceImp.OnIAPInitStart();
|
||||
}
|
||||
|
||||
private void OnIAPInitComplete(bool success)
|
||||
private static void OnIAPInitComplete(bool success)
|
||||
{
|
||||
Log.I($"[GuruCallback][OnIAPInitComplete] success:{success}");
|
||||
_serviceImp.OnIAPInitComplete(success);
|
||||
}
|
||||
|
||||
private void OnPurchaseStart(string productName)
|
||||
private static void OnPurchaseStart(string productName)
|
||||
{
|
||||
Log.I($"[GuruCallback][OnPurchaseStart] productName:{productName}");
|
||||
ShowIAPLoadingView();
|
||||
_serviceImp.OnPurchaseStart(productName);
|
||||
}
|
||||
|
||||
private void OnPurchaseEnd(string productName, bool success)
|
||||
private static void OnPurchaseEnd(string productName, bool success)
|
||||
{
|
||||
Log.I($"[GuruCallback][OnPurchaseEnd] productName:{productName}, success:{success}");
|
||||
CloseIAPLoadingView();
|
||||
_serviceImp.OnPurchaseEnd(productName, success);
|
||||
}
|
||||
|
||||
private void OnPurchaseFailed(string productName, string reason)
|
||||
private static void OnPurchaseFailed(string productName, string reason)
|
||||
{
|
||||
Log.I($"[GuruCallback][OnPurchaseFailed] productName:{productName}, reason:{reason}");
|
||||
_serviceImp.OnPurchaseFailed(productName, reason);
|
||||
}
|
||||
|
||||
private void OnIAPRestored(bool success, string msg)
|
||||
private static void OnIAPRestored(bool success, string msg)
|
||||
{
|
||||
Log.I($"[GuruCallback][OnIAPRestored] success:{success}, msg:{msg}");
|
||||
_serviceImp.OnIAPRestored(success, msg);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 查询接口
|
||||
|
||||
public string GetProductCurrencyCode(string productName)
|
||||
public static string GetProductCurrencyCode(string productName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(productName))
|
||||
return Fallback();
|
||||
|
|
@ -68,7 +76,7 @@ namespace GuruSDKService
|
|||
}
|
||||
}
|
||||
|
||||
public string GetProductPriceString(string productName)
|
||||
public static string GetProductPriceString(string productName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(productName))
|
||||
return Fallback();
|
||||
|
|
@ -85,7 +93,7 @@ namespace GuruSDKService
|
|||
}
|
||||
}
|
||||
|
||||
public double GetProductPrice(string productName)
|
||||
public static double GetProductPrice(string productName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(productName))
|
||||
return Fallback();
|
||||
|
|
@ -104,9 +112,9 @@ namespace GuruSDKService
|
|||
|
||||
#endregion
|
||||
|
||||
public void ShowIAPLoadingView() => _serviceImp.ShowIAPBuyLoadingView();
|
||||
public void CloseIAPLoadingView() => _serviceImp.CloseIAPLoadingView();
|
||||
public void IAPBuySuccessTip() => _serviceImp.IAPBuySuccessTip();
|
||||
public void IAPBuyFailTip() => _serviceImp.IAPBuyFailTip();
|
||||
public static void ShowIAPLoadingView() => _serviceImp.ShowIAPBuyLoadingView();
|
||||
public static void CloseIAPLoadingView() => _serviceImp.CloseIAPLoadingView();
|
||||
public static void IAPBuySuccessTip() => _serviceImp.IAPBuySuccessTip();
|
||||
public static void IAPBuyFailTip() => _serviceImp.IAPBuyFailTip();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,24 +1,24 @@
|
|||
using Guru;
|
||||
|
||||
namespace GuruSDKService
|
||||
namespace GuruService
|
||||
{
|
||||
public partial class GuruSDKService
|
||||
public static partial class GuruSDKService
|
||||
{
|
||||
private void InitSDKModel()
|
||||
private static void InitSDKModel()
|
||||
{
|
||||
if (_serviceImp != null)
|
||||
{
|
||||
SetGuruSDK_BLevel(_serviceImp.b_level);
|
||||
SetGuruSDK_BPlay(_serviceImp.b_play);
|
||||
SetGuruSDK_BLevel(_serviceImp.GetBLevel());
|
||||
SetGuruSDK_BPlay(_serviceImp.GetBPlay());
|
||||
}
|
||||
}
|
||||
|
||||
public void SetGuruSDK_BLevel(int level)
|
||||
public static void SetGuruSDK_BLevel(int level)
|
||||
{
|
||||
GuruSDK.SuccessLevelCount = level;
|
||||
}
|
||||
|
||||
public void SetGuruSDK_BPlay(int play)
|
||||
public static void SetGuruSDK_BPlay(int play)
|
||||
{
|
||||
GuruSDK.TotalPlayedCount = play;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,23 +2,23 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using Guru;
|
||||
|
||||
namespace GuruSDKService
|
||||
namespace GuruService
|
||||
{
|
||||
public partial class GuruSDKService : Singleton<GuruSDKService>
|
||||
public static partial class GuruSDKService
|
||||
{
|
||||
private bool _initService;
|
||||
private IGuruSDKServiceImp _serviceImp;
|
||||
|
||||
public void InitService(IGuruSDKServiceImp serviceImp, Action onFirebaseReady)
|
||||
private static bool _initService;
|
||||
private static IGuruSDKServiceImp _serviceImp;
|
||||
|
||||
public static void InitService(IGuruSDKServiceImp serviceImp, Action onFirebaseReady)
|
||||
{
|
||||
if(_initService) return;
|
||||
if (_initService) return;
|
||||
_initService = true;
|
||||
_serviceImp = serviceImp;
|
||||
_onFirebaseReady = onFirebaseReady;
|
||||
InitSDKModel();
|
||||
AddCallbackListener();
|
||||
AddIAPCallbackListener();
|
||||
|
||||
|
||||
Guru.Analytics.EnableTch02Event = true;
|
||||
GuruSDKInitConfig config = new GuruSDKInitConfig
|
||||
{
|
||||
|
|
|
|||
|
|
@ -0,0 +1,102 @@
|
|||
using System.Collections.Generic;
|
||||
using Guru;
|
||||
|
||||
namespace GuruService
|
||||
{
|
||||
public abstract class GuruSDKServiceImpBase : IGuruSDKServiceImp
|
||||
{
|
||||
public virtual string CustomServiceKey => "";
|
||||
public virtual string BannerBackgroundColor => "#00000000";
|
||||
public abstract bool IsNoAD { get; }
|
||||
public abstract bool IsIAPEnabled { get; }
|
||||
public abstract bool IsDebugMode { get; }
|
||||
public abstract Dictionary<string, object> GetDefaultRemoteData();
|
||||
|
||||
public virtual byte[] GetGooglePlayTangleData()
|
||||
{
|
||||
if (!IsIAPEnabled) return null;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
return null;
|
||||
#else
|
||||
return GooglePlayTangle.Data();
|
||||
#endif
|
||||
}
|
||||
|
||||
public virtual byte[] GetAppleTangleData()
|
||||
{
|
||||
if (!IsIAPEnabled) return null;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
return null;
|
||||
#else
|
||||
return AppleTangle.Data();
|
||||
#endif
|
||||
}
|
||||
|
||||
public void SetBLevel(int level)
|
||||
{
|
||||
GuruSDKService.SetGuruSDK_BLevel(level);
|
||||
}
|
||||
|
||||
public abstract int GetBLevel();
|
||||
|
||||
public void SetBPlay(int play)
|
||||
{
|
||||
GuruSDKService.SetGuruSDK_BPlay(play);
|
||||
}
|
||||
|
||||
public abstract int GetBPlay();
|
||||
|
||||
public abstract void OnAppPaused(bool paused);
|
||||
|
||||
public abstract void OnAppQuit();
|
||||
|
||||
public abstract void OnFirebaseReady(bool success);
|
||||
|
||||
public abstract void OnGuruServiceReady();
|
||||
|
||||
public abstract void OnUserAuthResult(bool success);
|
||||
|
||||
public abstract void OnFirebaseAuthResult(bool success);
|
||||
|
||||
public abstract void OnAttResult(int authorizationTrackingStatus);
|
||||
|
||||
public abstract void OnConsentResult(int statusCode);
|
||||
|
||||
public abstract void OnAdsInitComplete();
|
||||
|
||||
public abstract void OnBannerADLoaded();
|
||||
|
||||
public abstract void OnInterstitialADLoaded();
|
||||
|
||||
public abstract void OnInterstitialADFailed();
|
||||
|
||||
public abstract void OnRewardedADLoaded();
|
||||
|
||||
public abstract void OnRewardADFailed();
|
||||
|
||||
public abstract void OnRemoteFetchComplete(bool success);
|
||||
|
||||
public abstract void OnIAPInitStart();
|
||||
|
||||
public abstract void OnIAPInitComplete(bool success);
|
||||
|
||||
public abstract void OnPurchaseStart(string productName);
|
||||
|
||||
public abstract void OnPurchaseEnd(string productName, bool success);
|
||||
|
||||
public abstract void OnPurchaseFailed(string productName, string reason);
|
||||
|
||||
public abstract void OnIAPRestored(bool success, string msg);
|
||||
|
||||
public abstract void ShowIAPBuyLoadingView();
|
||||
|
||||
public abstract void CloseIAPLoadingView();
|
||||
|
||||
public abstract void IAPBuySuccessTip();
|
||||
|
||||
public abstract void IAPBuyFailTip();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fb94a80a939d4b23bf623ad568378846
|
||||
timeCreated: 1712103240
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace GuruSDKService
|
||||
namespace GuruService
|
||||
{
|
||||
public interface IGuruSDKServiceImp
|
||||
{
|
||||
|
|
@ -14,16 +14,18 @@ namespace GuruSDKService
|
|||
Dictionary<string, object> GetDefaultRemoteData();
|
||||
byte[] GetGooglePlayTangleData();
|
||||
byte[] GetAppleTangleData();
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Model映射
|
||||
|
||||
int b_level { get; set; }
|
||||
int b_play { get; set; }
|
||||
void SetBLevel(int level);
|
||||
int GetBLevel();
|
||||
void SetBPlay(int play);
|
||||
int GetBPlay();
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Callbacks回调
|
||||
|
||||
void OnAppPaused(bool paused);
|
||||
|
|
@ -33,10 +35,10 @@ namespace GuruSDKService
|
|||
void OnGuruServiceReady();
|
||||
void OnUserAuthResult(bool success);
|
||||
void OnFirebaseAuthResult(bool success);
|
||||
|
||||
|
||||
void OnAttResult(int authorizationTrackingStatus);
|
||||
void OnConsentResult(int statusCode);
|
||||
|
||||
|
||||
void OnAdsInitComplete();
|
||||
void OnBannerADLoaded();
|
||||
void OnInterstitialADLoaded();
|
||||
|
|
@ -61,7 +63,7 @@ namespace GuruSDKService
|
|||
void CloseIAPLoadingView();
|
||||
void IAPBuySuccessTip();
|
||||
void IAPBuyFailTip();
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue