2023-12-26 03:40:48 +00:00
|
|
|
namespace Guru
|
|
|
|
|
{
|
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public partial class GuruSDK
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 回调参数类
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class Callbacks
|
|
|
|
|
{
|
2023-12-27 12:24:16 +00:00
|
|
|
/// <summary>
|
|
|
|
|
/// APP 事件
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static class App
|
|
|
|
|
{
|
2024-07-31 04:56:01 +00:00
|
|
|
private static Action<bool> _onAppPaused;
|
2023-12-27 12:24:16 +00:00
|
|
|
public static event Action<bool> OnAppPaused
|
|
|
|
|
{
|
|
|
|
|
add => _onAppPaused += value;
|
|
|
|
|
remove => _onAppPaused -= value;
|
|
|
|
|
}
|
2024-07-31 04:56:01 +00:00
|
|
|
internal static void InvokeOnAppPaused(bool isPaused)
|
|
|
|
|
{
|
|
|
|
|
_onAppPaused?.Invoke(isPaused);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Action _onAppQuit;
|
2023-12-27 12:24:16 +00:00
|
|
|
public static event Action OnAppQuit
|
|
|
|
|
{
|
|
|
|
|
add => _onAppQuit += value;
|
|
|
|
|
remove => _onAppQuit -= value;
|
|
|
|
|
}
|
2024-07-31 04:56:01 +00:00
|
|
|
internal static void InvokeOnAppQuit()
|
|
|
|
|
{
|
|
|
|
|
_onAppQuit?.Invoke();
|
|
|
|
|
}
|
2023-12-27 12:24:16 +00:00
|
|
|
}
|
2024-07-31 04:56:01 +00:00
|
|
|
|
2023-12-26 03:40:48 +00:00
|
|
|
/// <summary>
|
|
|
|
|
/// GDPR Consent
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static class ConsentFlow
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 当Consent启动结束后返回状态码
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static event Action<int> OnConsentResult
|
|
|
|
|
{
|
|
|
|
|
add => _onConsentResult += value;
|
|
|
|
|
remove => _onConsentResult -= value;
|
|
|
|
|
}
|
2024-07-31 04:56:01 +00:00
|
|
|
private static Action<int> _onConsentResult;
|
|
|
|
|
internal static void InvokeOnConsentResult(int code)
|
|
|
|
|
{
|
|
|
|
|
_onConsentResult?.Invoke(code);
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-26 03:40:48 +00:00
|
|
|
/// <summary>
|
|
|
|
|
/// ATT 状态返回
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static event Action<int> OnAttResult
|
|
|
|
|
{
|
|
|
|
|
add => _onAttResult += value;
|
|
|
|
|
remove => _onAttResult -= value;
|
|
|
|
|
}
|
2024-07-31 04:56:01 +00:00
|
|
|
private static Action<int> _onAttResult;
|
|
|
|
|
internal static void InvokeOnAttResultCallback(int code)
|
|
|
|
|
{
|
|
|
|
|
_onAttResult?.Invoke(code);
|
|
|
|
|
}
|
2023-12-26 03:40:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 广告回调
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static class Ads
|
|
|
|
|
{
|
2024-07-31 04:56:01 +00:00
|
|
|
private static Action _onAdsInitComplete;
|
2023-12-26 03:40:48 +00:00
|
|
|
public static event Action OnAdsInitComplete
|
|
|
|
|
{
|
|
|
|
|
add => _onAdsInitComplete += value;
|
|
|
|
|
remove => _onAdsInitComplete -= value;
|
|
|
|
|
}
|
2024-07-31 04:56:01 +00:00
|
|
|
internal static void InvokeOnAdsInitComplete()
|
|
|
|
|
{
|
|
|
|
|
_onAdsInitComplete?.Invoke();
|
|
|
|
|
}
|
2023-12-26 03:40:48 +00:00
|
|
|
|
2024-07-02 04:36:15 +00:00
|
|
|
//------------ BANNER -----------------
|
2024-07-31 04:56:01 +00:00
|
|
|
private static Action<string> _onBannerADStartLoad;
|
2024-05-07 12:37:57 +00:00
|
|
|
public static event Action<string> OnBannerADStartLoad
|
|
|
|
|
{
|
|
|
|
|
add => _onBannerADStartLoad += value;
|
|
|
|
|
remove => _onBannerADStartLoad -= value;
|
|
|
|
|
}
|
2024-07-31 04:56:01 +00:00
|
|
|
internal static void InvokeOnBannerADStartLoad(string adUnitId)
|
|
|
|
|
{
|
|
|
|
|
_onBannerADStartLoad?.Invoke(adUnitId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Action _onBannerADLoaded;
|
2024-01-17 09:51:08 +00:00
|
|
|
public static event Action OnBannerADLoaded
|
|
|
|
|
{
|
|
|
|
|
add => _onBannerADLoaded += value;
|
|
|
|
|
remove => _onBannerADLoaded -= value;
|
|
|
|
|
}
|
2024-07-31 04:56:01 +00:00
|
|
|
internal static void InvokeOnBannerADLoaded()
|
|
|
|
|
{
|
|
|
|
|
_onBannerADLoaded?.Invoke();
|
|
|
|
|
}
|
2024-01-17 09:51:08 +00:00
|
|
|
|
2024-07-02 04:36:15 +00:00
|
|
|
//------------ INTER -----------------
|
2024-07-31 04:56:01 +00:00
|
|
|
private static Action<string> _onInterstitialADStartLoad;
|
2024-05-07 12:37:57 +00:00
|
|
|
public static event Action<string> OnInterstitialADStartLoad
|
|
|
|
|
{
|
|
|
|
|
add => _onInterstitialADStartLoad += value;
|
|
|
|
|
remove => _onInterstitialADStartLoad -= value;
|
|
|
|
|
}
|
2024-07-31 04:56:01 +00:00
|
|
|
internal static void InvokeOnInterstitialADStartLoad(string adUnitId)
|
|
|
|
|
{
|
|
|
|
|
_onInterstitialADStartLoad?.Invoke(adUnitId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Action _onInterstitialADLoaded;
|
2023-12-26 03:40:48 +00:00
|
|
|
public static event Action OnInterstitialADLoaded
|
|
|
|
|
{
|
|
|
|
|
add => _onInterstitialADLoaded += value;
|
|
|
|
|
remove => _onInterstitialADLoaded -= value;
|
|
|
|
|
}
|
2024-07-31 04:56:01 +00:00
|
|
|
internal static void InvokeOnInterstitialADLoaded()
|
|
|
|
|
{
|
|
|
|
|
_onInterstitialADLoaded?.Invoke();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Action _onInterstitialADFailed;
|
2023-12-26 03:40:48 +00:00
|
|
|
public static event Action OnInterstitialADFailed
|
|
|
|
|
{
|
|
|
|
|
add => _onInterstitialADFailed += value;
|
|
|
|
|
remove => _onInterstitialADFailed -= value;
|
|
|
|
|
}
|
2024-07-31 04:56:01 +00:00
|
|
|
internal static void InvokeOnInterstitialADFailed()
|
|
|
|
|
{
|
|
|
|
|
_onInterstitialADFailed?.Invoke();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Action _onInterstitialADClosed;
|
2024-07-02 04:36:15 +00:00
|
|
|
public static event Action OnInterstitialADClosed
|
|
|
|
|
{
|
|
|
|
|
add => _onInterstitialADClosed += value;
|
|
|
|
|
remove => _onInterstitialADClosed -= value;
|
|
|
|
|
}
|
2024-07-31 04:56:01 +00:00
|
|
|
internal static void InvokeOnInterstitialADClosed()
|
|
|
|
|
{
|
|
|
|
|
_onInterstitialADClosed?.Invoke();
|
|
|
|
|
}
|
2023-12-26 03:40:48 +00:00
|
|
|
|
2024-07-02 04:36:15 +00:00
|
|
|
//------------ REWARD -----------------
|
2024-07-31 04:56:01 +00:00
|
|
|
private static Action<string> _onRewardedADStartLoad;
|
2024-05-07 12:37:57 +00:00
|
|
|
public static event Action<string> OnRewardedADStartLoad
|
|
|
|
|
{
|
|
|
|
|
add => _onRewardedADStartLoad += value;
|
|
|
|
|
remove => _onRewardedADStartLoad -= value;
|
|
|
|
|
}
|
2024-07-31 04:56:01 +00:00
|
|
|
internal static void InvokeOnRewardedADStartLoad(string adUnitId)
|
|
|
|
|
{
|
|
|
|
|
_onRewardedADStartLoad?.Invoke(adUnitId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Action _onRewardedADLoaded;
|
2023-12-26 03:40:48 +00:00
|
|
|
public static event Action OnRewardedADLoaded
|
|
|
|
|
{
|
|
|
|
|
add => _onRewardedADLoaded += value;
|
|
|
|
|
remove => _onRewardedADLoaded -= value;
|
|
|
|
|
}
|
2024-07-31 04:56:01 +00:00
|
|
|
internal static void InvokeOnRewardedADLoaded()
|
|
|
|
|
{
|
|
|
|
|
_onRewardedADLoaded?.Invoke();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Action _onRewardADClosed;
|
2024-07-02 04:36:15 +00:00
|
|
|
public static event Action OnRewardedADClosed
|
|
|
|
|
{
|
|
|
|
|
add => _onRewardADClosed += value;
|
|
|
|
|
remove => _onRewardADClosed -= value;
|
|
|
|
|
}
|
2024-07-31 04:56:01 +00:00
|
|
|
internal static void InvokeOnRewardADClosed()
|
|
|
|
|
{
|
|
|
|
|
_onRewardADClosed?.Invoke();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Action _onRewardADFailed;
|
2023-12-26 03:40:48 +00:00
|
|
|
public static event Action OnRewardADFailed
|
|
|
|
|
{
|
|
|
|
|
add => _onRewardADFailed += value;
|
|
|
|
|
remove => _onRewardADFailed -= value;
|
|
|
|
|
}
|
2024-07-31 04:56:01 +00:00
|
|
|
internal static void InvokeOnRewardADFailed()
|
|
|
|
|
{
|
|
|
|
|
_onRewardADFailed?.Invoke();
|
|
|
|
|
}
|
2023-12-26 03:40:48 +00:00
|
|
|
}
|
|
|
|
|
|
2023-12-27 12:24:16 +00:00
|
|
|
/// <summary>
|
|
|
|
|
/// 云控参数
|
|
|
|
|
/// </summary>
|
2023-12-26 03:40:48 +00:00
|
|
|
public static class Remote
|
|
|
|
|
{
|
2024-07-31 04:56:01 +00:00
|
|
|
private static Action<bool> _onRemoteFetchComplete;
|
2023-12-27 12:24:16 +00:00
|
|
|
public static event Action<bool> OnRemoteFetchComplete
|
|
|
|
|
{
|
|
|
|
|
add => _onRemoteFetchComplete += value;
|
|
|
|
|
remove => _onRemoteFetchComplete -= value;
|
|
|
|
|
}
|
2024-07-31 04:56:01 +00:00
|
|
|
internal static void InvokeOnRemoteFetchComplete(bool success)
|
|
|
|
|
{
|
|
|
|
|
_onRemoteFetchComplete?.Invoke(success);
|
|
|
|
|
}
|
2023-12-27 12:24:16 +00:00
|
|
|
}
|
2023-12-26 03:40:48 +00:00
|
|
|
|
2023-12-27 12:24:16 +00:00
|
|
|
/// <summary>
|
|
|
|
|
/// 支付回调
|
|
|
|
|
/// </summary>
|
2023-12-26 03:40:48 +00:00
|
|
|
public static class IAP
|
|
|
|
|
{
|
2024-07-31 04:56:01 +00:00
|
|
|
private static Action _onIAPInitStart;
|
2024-03-18 02:22:11 +00:00
|
|
|
public static event Action OnIAPInitStart
|
|
|
|
|
{
|
|
|
|
|
add => _onIAPInitStart += value;
|
|
|
|
|
remove => _onIAPInitStart -= value;
|
|
|
|
|
}
|
2024-07-31 04:56:01 +00:00
|
|
|
internal static void InvokeOnIAPInitStart()
|
|
|
|
|
{
|
|
|
|
|
_onIAPInitStart?.Invoke();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static Action<bool> _onIAPInitComplete;
|
2023-12-26 03:40:48 +00:00
|
|
|
public static event Action<bool> OnIAPInitComplete
|
|
|
|
|
{
|
|
|
|
|
add => _onIAPInitComplete += value;
|
|
|
|
|
remove => _onIAPInitComplete -= value;
|
|
|
|
|
}
|
2024-07-31 04:56:01 +00:00
|
|
|
internal static void InvokeOnIAPInitComplete(bool success)
|
|
|
|
|
{
|
|
|
|
|
_onIAPInitComplete?.Invoke(success);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static Action<string> _onPurchaseStart;
|
2023-12-26 03:40:48 +00:00
|
|
|
public static event Action<string> OnPurchaseStart
|
|
|
|
|
{
|
|
|
|
|
add => _onPurchaseStart += value;
|
|
|
|
|
remove => _onPurchaseStart -= value;
|
|
|
|
|
}
|
2024-07-31 04:56:01 +00:00
|
|
|
internal static void InvokeOnPurchaseStart(string productId)
|
|
|
|
|
{
|
|
|
|
|
_onPurchaseStart?.Invoke(productId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static Action<string, bool> _onPurchaseEnd;
|
2024-03-18 02:22:11 +00:00
|
|
|
public static event Action<string, bool> OnPurchaseEnd
|
|
|
|
|
{
|
|
|
|
|
add => _onPurchaseEnd += value;
|
|
|
|
|
remove => _onPurchaseEnd -= value;
|
|
|
|
|
}
|
2024-07-31 04:56:01 +00:00
|
|
|
internal static void InvokeOnPurchaseEnd(string productId, bool success)
|
|
|
|
|
{
|
|
|
|
|
_onPurchaseEnd?.Invoke(productId, success);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static Action<string, string> _onPurchaseFailed;
|
2023-12-28 11:29:04 +00:00
|
|
|
public static event Action<string, string> OnPurchaseFailed
|
|
|
|
|
{
|
|
|
|
|
add => _onPurchaseFailed += value;
|
|
|
|
|
remove => _onPurchaseFailed -= value;
|
|
|
|
|
}
|
2024-07-31 04:56:01 +00:00
|
|
|
internal static void InvokeOnPurchaseFailed(string productId, string error)
|
|
|
|
|
{
|
|
|
|
|
_onPurchaseFailed?.Invoke(productId, error);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static Action<bool, string> _onIAPRestored;
|
2024-01-23 05:57:09 +00:00
|
|
|
public static event Action<bool, string> OnIAPRestored
|
|
|
|
|
{
|
|
|
|
|
add => _onIAPRestored += value;
|
|
|
|
|
remove => _onIAPRestored -= value;
|
|
|
|
|
}
|
2024-07-31 04:56:01 +00:00
|
|
|
internal static void InvokeOnIAPRestored(bool success, string productId)
|
|
|
|
|
{
|
|
|
|
|
_onIAPRestored?.Invoke(success, productId);
|
|
|
|
|
}
|
2023-12-26 03:40:48 +00:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-15 04:59:20 +00:00
|
|
|
|
|
|
|
|
public static class SDK
|
|
|
|
|
{
|
2024-07-31 04:56:01 +00:00
|
|
|
private static Action<bool> _onFirebaseReady;
|
2024-03-15 04:59:20 +00:00
|
|
|
public static event Action<bool> OnFirebaseReady
|
|
|
|
|
{
|
|
|
|
|
add => _onFirebaseReady += value;
|
|
|
|
|
remove => _onFirebaseReady -= value;
|
|
|
|
|
}
|
2024-07-31 04:56:01 +00:00
|
|
|
internal static void InvokeOnFirebaseReady(bool success)
|
|
|
|
|
{
|
|
|
|
|
_onFirebaseReady?.Invoke(success);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Action _onGuruServiceReady;
|
2024-03-15 09:00:40 +00:00
|
|
|
public static event Action OnGuruServiceReady
|
|
|
|
|
{
|
|
|
|
|
add => _onGuruServiceReady += value;
|
|
|
|
|
remove => _onGuruServiceReady -= value;
|
|
|
|
|
}
|
2024-07-31 04:56:01 +00:00
|
|
|
internal static void InvokeOnGuruServiceReady()
|
|
|
|
|
{
|
|
|
|
|
_onGuruServiceReady?.Invoke();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Action<bool> _onDebuggerDisplayed;
|
2024-03-22 05:20:54 +00:00
|
|
|
public static event Action<bool> OnDisplayDebugger
|
|
|
|
|
{
|
|
|
|
|
add => _onDebuggerDisplayed += value;
|
|
|
|
|
remove => _onDebuggerDisplayed -= value;
|
|
|
|
|
}
|
2024-07-31 04:56:01 +00:00
|
|
|
internal static void InvokeOnDebuggerDisplayed(bool success)
|
|
|
|
|
{
|
|
|
|
|
_onDebuggerDisplayed?.Invoke(success);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Action<bool> _onUserAuthResult;
|
2024-07-31 12:59:36 +00:00
|
|
|
public static event Action<bool> OnGuruUserAuthResult
|
2024-03-31 09:18:43 +00:00
|
|
|
{
|
2024-03-31 10:08:26 +00:00
|
|
|
add => _onUserAuthResult += value;
|
|
|
|
|
remove => _onUserAuthResult -= value;
|
2024-03-31 09:18:43 +00:00
|
|
|
}
|
2024-07-31 12:59:36 +00:00
|
|
|
internal static void InvokeOnGuruUserAuthResult(bool success)
|
2024-07-31 04:56:01 +00:00
|
|
|
{
|
|
|
|
|
_onUserAuthResult?.Invoke(success);
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-12 02:29:30 +00:00
|
|
|
// DeepLink 回调
|
2024-07-30 12:31:41 +00:00
|
|
|
private static Action<string> _onDeeplinkCallback;
|
2024-07-12 02:29:30 +00:00
|
|
|
public static event Action<string> OnDeeplinkCallback
|
|
|
|
|
{
|
|
|
|
|
add => _onDeeplinkCallback += value;
|
|
|
|
|
remove => _onDeeplinkCallback -= value;
|
|
|
|
|
}
|
2024-07-30 12:31:41 +00:00
|
|
|
internal static void InvokeDeeplinkCallback(string deeplink)
|
|
|
|
|
{
|
|
|
|
|
_onDeeplinkCallback?.Invoke(deeplink);
|
|
|
|
|
}
|
2024-07-12 02:29:30 +00:00
|
|
|
|
2024-08-11 07:35:43 +00:00
|
|
|
// TODO: 之后需要添加 define 宏来控制是否可用
|
|
|
|
|
// Firebase Auth 回调
|
|
|
|
|
private static Action<bool, Firebase.Auth.FirebaseUser> _onFirebaseUserAuthResult;
|
|
|
|
|
public static event Action<bool, Firebase.Auth.FirebaseUser> OnFirebaseUserAuthResult
|
|
|
|
|
{
|
|
|
|
|
add => _onFirebaseUserAuthResult += value;
|
|
|
|
|
remove => _onFirebaseUserAuthResult -= value;
|
|
|
|
|
}
|
|
|
|
|
internal static void InvokeOnFirebaseAuthResult(bool success, Firebase.Auth.FirebaseUser firebaseUser = null)
|
|
|
|
|
{
|
|
|
|
|
_onFirebaseUserAuthResult?.Invoke(success, firebaseUser);
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-15 04:59:20 +00:00
|
|
|
}
|
|
|
|
|
|
2023-12-26 03:40:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|