update: 添加广告启动初始化配置对象
parent
1f71522fa6
commit
4fadb2b469
|
|
@ -8,21 +8,23 @@ namespace Guru
|
|||
|
||||
public partial class GuruSDK
|
||||
{
|
||||
|
||||
|
||||
private static AdsInitSpec _adInitSpec;
|
||||
|
||||
/// <summary>
|
||||
/// 启动广告服务
|
||||
/// </summary>
|
||||
public static void StartAds()
|
||||
public static void StartAds(AdsInitSpec spec = null)
|
||||
{
|
||||
_adInitSpec = spec;
|
||||
if (InitConfig.UseCustomConsent)
|
||||
{
|
||||
Debug.Log($"{Tag} --- Call <color=orange>StartAdsWithCustomConsent</color> when you use custom consent, and pass the result (boolean) to the method.");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 默认的启动顺序是先启动Consent后, 根据用户回调的结果来启动广告
|
||||
Instance.StartConsentFlow();
|
||||
}
|
||||
|
||||
// 默认的启动顺序是先启动Consent后, 根据用户回调的结果来启动广告
|
||||
Instance.StartConsentFlow();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -30,7 +32,7 @@ namespace Guru
|
|||
/// </summary>
|
||||
/// <param name="userAllow"></param>
|
||||
/// <param name="guideType">Consent 引导的类型, 如果使用了 MAX 的 consent 请填写 max </param>
|
||||
public static void StartAdsWithCustomConsent(bool userAllow = true, string guideType = "custom")
|
||||
public static void StartAdsWithCustomConsent(bool userAllow = true, string guideType = "custom", AdsInitSpec spec = null)
|
||||
{
|
||||
#if UNITY_IOS
|
||||
_attType = guideType;
|
||||
|
|
@ -41,7 +43,7 @@ namespace Guru
|
|||
#if UNITY_IOS
|
||||
CheckAttStatus();
|
||||
#else
|
||||
StartAdService();
|
||||
StartAdService(spec);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
|
|
@ -87,7 +89,7 @@ namespace Guru
|
|||
private void OnGuruConsentOver(int code)
|
||||
{
|
||||
// 无论状态如何, 都在回调内启动广告初始化
|
||||
StartAdService();
|
||||
StartAdService(_adInitSpec);
|
||||
|
||||
// 调用回调
|
||||
Callbacks.ConsentFlow._onConsentResult?.Invoke(code);
|
||||
|
|
@ -187,11 +189,11 @@ namespace Guru
|
|||
/// <summary>
|
||||
/// 启动广告服务
|
||||
/// </summary>
|
||||
public static void StartAdService()
|
||||
internal static void StartAdService(AdsInitSpec spec = null)
|
||||
{
|
||||
LogI($"StartAdService");
|
||||
ADService.Instance.StartService(OnAdsInitComplete,
|
||||
InitConfig.AutoLoadWhenAdsReady, IsDebugMode);
|
||||
if(spec == null) spec = AdsInitSpec.BuildDefault(InitConfig.AutoLoadWhenAdsReady, IsDebugMode);
|
||||
ADService.Instance.StartService(OnAdsInitComplete, spec);
|
||||
|
||||
//--------- Callbacks -----------
|
||||
ADService.OnBannerLoaded = OnBannerLoaded;
|
||||
|
|
@ -203,7 +205,6 @@ namespace Guru
|
|||
|
||||
private static void OnBannerLoaded()
|
||||
=> Callbacks.Ads._onBannerADLoaded?.Invoke();
|
||||
|
||||
private static void OnInterstitialLoaded()
|
||||
=> Callbacks.Ads._onInterstitialADLoaded?.Invoke();
|
||||
private static void OnInterstitialFailed()
|
||||
|
|
@ -323,4 +324,8 @@ namespace Guru
|
|||
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -167,6 +167,15 @@ namespace Guru
|
|||
add => _onFirebaseReady += value;
|
||||
remove => _onFirebaseReady -= value;
|
||||
}
|
||||
|
||||
internal static Action _onGuruServiceReady;
|
||||
public static event Action OnGuruServiceReady
|
||||
{
|
||||
add => _onGuruServiceReady += value;
|
||||
remove => _onGuruServiceReady -= value;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -332,6 +332,9 @@ namespace Guru
|
|||
Debug.LogError($"--- ERROR on StartConsentFlow: {ex.Message}");
|
||||
});
|
||||
}
|
||||
|
||||
// 中台服务初始化结束
|
||||
Callbacks.SDK._onGuruServiceReady?.Invoke();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
Loading…
Reference in New Issue