namespace Guru
{
using System.Collections.Generic;
using System.Text;
using System;
///
/// 启动参数配置
///
public class GuruSDKInitConfig
{
///
/// 使用自定义的ConsentFlow启动流程
///
public bool UseCustomConsent = false;
///
/// SDK初始化完成后自动加载广告
///
public bool AutoLoadWhenAdsReady = true;
///
/// 使用IAP支付插件功能
///
public bool IAPEnabled = true;
///
/// 自动记录完成的关卡
///
public bool AutoRecordFinishedLevels = false;
///
/// 自定义 Service 云控 Key
///
public string CustomServiceKey = "";
///
/// DeepLink 回调
///
public Action OnAdjustDeeplinkCallback;
///
/// Banner 背景颜色 Hex 值
///
public string BannerBackgroundColor = "#00000000";
///
/// 已购买去广告道具
///
public bool IsBuyNoAds = false;
///
/// Debug模式(默认关闭)
///
public bool DebugMode = false;
///
/// 云控参数的默认配置
///
///
public Dictionary DefaultRemoteData = new Dictionary();
///
/// 支付初始化Keys
///
public byte[] GoogleKeys; // 数据取自 GooglePlayTangle.Data();
public byte[] AppleRootCerts; // 数据取自 AppleTangle.Data();
#region Initialization
///
/// 构建启动配置
///
///
[Obsolete("此方法将在下个版本中被废弃, 请直接使用 GuruSDKInitConfig.Builder 来进行初始化。 例如:GuruSDKInitConfig.Builder().SetIsBuyNoAds(true).Build()")]
public static GuruSDKInitConfig Build(
bool useCustomConsent = false,
bool autoLoadAds = true,
bool iapEnabled = true,
bool autoRecordFinishedLevels = false,
bool isBuyNoAds = false,
Action onDeeplinkCallback = null,
string bannerBackgroundColor = "#00000000",
bool debugMode = false,
Dictionary defaultRemoteData = null,
byte[] googleKeys = null,
byte[] appleRootCerts = null)
{
// 创建启动用参数
GuruSDKInitConfig config = new GuruSDKInitConfig()
{
UseCustomConsent = useCustomConsent,
AutoLoadWhenAdsReady = autoLoadAds,
IAPEnabled = iapEnabled,
AutoRecordFinishedLevels = autoRecordFinishedLevels,
IsBuyNoAds = isBuyNoAds,
BannerBackgroundColor = bannerBackgroundColor,
DebugMode = debugMode,
GoogleKeys = googleKeys,
AppleRootCerts = appleRootCerts,
OnAdjustDeeplinkCallback = onDeeplinkCallback,
DefaultRemoteData = defaultRemoteData ?? new Dictionary(),
};
#if UNITY_EDITOR
config.DebugMode = true;
#endif
return config;
}
#endregion
#region Print
public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.AppendLine($"------- Custom init Config -------");
sb.AppendLine($"\tUseCustomConsent: {UseCustomConsent}");
sb.AppendLine($"\tAutoLoadWhenAdsReady: {AutoLoadWhenAdsReady}");
sb.AppendLine($"\tAutoRecordFinishedLevels: {AutoRecordFinishedLevels}");
sb.AppendLine($"\tIsBuyNoAds: {IsBuyNoAds}");
sb.AppendLine($"\tOnDeeplinkCallback: {OnAdjustDeeplinkCallback}");
sb.AppendLine($"\tDefaultRemoteData: {DefaultRemoteData}");
sb.AppendLine($"\tGoogleKeys: {GoogleKeys}");
sb.AppendLine($"\tAppleRootCerts: {AppleRootCerts}");
sb.AppendLine($"\tDebugMode: {DebugMode}");
sb.AppendLine($"\tIAPEnabled: {IAPEnabled}");
sb.AppendLine($"\tBannerBackgroundColor: {BannerBackgroundColor}");
sb.AppendLine($"\tCustomServiceKey: {CustomServiceKey}");
sb.AppendLine($"------- Custom init Config -------");
return sb.ToString();
}
#endregion
#region Builder
///
/// 构造器
///
///
public static GuruSDKInitConfigBuilder Builder() => new GuruSDKInitConfigBuilder();
#endregion
}
///
/// 构建器
///
public class GuruSDKInitConfigBuilder
{
private readonly GuruSDKInitConfig _config = new GuruSDKInitConfig();
///
/// 构建配置
///
///
public GuruSDKInitConfig Build()
{
return _config;
}
public GuruSDKInitConfigBuilder SetUseCustomConsent(bool value)
{
_config.UseCustomConsent = value;
return this;
}
public GuruSDKInitConfigBuilder SetAutoLoadWhenAdsReady(bool value)
{
_config.AutoLoadWhenAdsReady = value;
return this;
}
public GuruSDKInitConfigBuilder SetIAPEnabled(bool value)
{
_config.IAPEnabled = value;
return this;
}
public GuruSDKInitConfigBuilder SetAutoRecordFinishedLevels(bool value)
{
_config.AutoRecordFinishedLevels = value;
return this;
}
public GuruSDKInitConfigBuilder SetIsBuyNoAds(bool value)
{
_config.IsBuyNoAds = value;
return this;
}
public GuruSDKInitConfigBuilder SetBannerBackgroundColor(string value)
{
_config.BannerBackgroundColor = value;
return this;
}
public GuruSDKInitConfigBuilder SetDebugMode(bool value)
{
_config.DebugMode = value;
return this;
}
public GuruSDKInitConfigBuilder SetOnAdjustDeeplinkCallback(Action callback)
{
_config.OnAdjustDeeplinkCallback = callback;
return this;
}
public GuruSDKInitConfigBuilder SetGoogleKeys(byte[] value)
{
_config.GoogleKeys = value;
return this;
}
public GuruSDKInitConfigBuilder SetAppleRootCerts(byte[] value)
{
_config.AppleRootCerts = value;
return this;
}
public GuruSDKInitConfigBuilder SetDefaultRemoteData(Dictionary value)
{
_config.DefaultRemoteData = value;
return this;
}
// public GuruSDKInitConfigBuilder SetEnableDebugLogEvent(bool value)
// {
// _config.EnableDebugLogEvent = value;
// return this;
// }
// public GuruSDKInitConfigBuilder SetCustomAnalyticsInitConfig(GuruAnalyticsInitConfig value)
// {
// _config.CustomAnalyticsInitConfig = value;
// return this;
// }
public GuruSDKInitConfigBuilder SetCustomServiceKey(string value)
{
_config.CustomServiceKey = value;
return this;
}
// public GuruSDKInitConfigBuilder SetAutoNotificationPermission(bool value)
// {
// _config.AutoNotificationPermission = value;
// return this;
// }
}
}