2023-12-26 03:40:48 +00:00
|
|
|
|
namespace Guru
|
|
|
|
|
|
{
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Text;
|
2024-08-13 10:48:19 +00:00
|
|
|
|
using System;
|
2023-12-26 03:40:48 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 启动参数配置
|
|
|
|
|
|
/// </summary>
|
2024-08-15 02:50:42 +00:00
|
|
|
|
public class GuruSDKInitConfig
|
2023-12-26 03:40:48 +00:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 使用自定义的ConsentFlow启动流程
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public bool UseCustomConsent = false;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// SDK初始化完成后自动加载广告
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public bool AutoLoadWhenAdsReady = true;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 使用IAP支付插件功能
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public bool IAPEnabled = true;
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 自动记录完成的关卡
|
|
|
|
|
|
/// </summary>
|
2024-08-15 02:50:42 +00:00
|
|
|
|
public bool AutoRecordFinishedLevels = false;
|
2023-12-26 03:40:48 +00:00
|
|
|
|
/// <summary>
|
2024-03-11 10:51:49 +00:00
|
|
|
|
/// 自定义 Service 云控 Key
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public string CustomServiceKey = "";
|
|
|
|
|
|
/// <summary>
|
2024-08-13 10:48:19 +00:00
|
|
|
|
/// DeepLink 回调
|
|
|
|
|
|
/// </summary>
|
2024-08-15 02:50:42 +00:00
|
|
|
|
public Action<string> OnAdjustDeeplinkCallback;
|
2024-08-13 10:48:19 +00:00
|
|
|
|
/// <summary>
|
2024-03-31 10:36:47 +00:00
|
|
|
|
/// Banner 背景颜色 Hex 值
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public string BannerBackgroundColor = "#00000000";
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 已购买去广告道具
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public bool IsBuyNoAds = false;
|
|
|
|
|
|
/// <summary>
|
2024-01-17 12:46:23 +00:00
|
|
|
|
/// Debug模式(默认关闭)
|
2023-12-26 03:40:48 +00:00
|
|
|
|
/// </summary>
|
2024-01-17 12:46:23 +00:00
|
|
|
|
public bool DebugMode = false;
|
2023-12-26 03:40:48 +00:00
|
|
|
|
/// <summary>
|
2023-12-28 07:54:00 +00:00
|
|
|
|
/// 云控参数的默认配置
|
2023-12-26 03:40:48 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public Dictionary<string, object> DefaultRemoteData = new Dictionary<string, object>();
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 支付初始化Keys
|
|
|
|
|
|
/// </summary>
|
2024-05-15 01:58:22 +00:00
|
|
|
|
public byte[] GoogleKeys; // 数据取自 GooglePlayTangle.Data();
|
|
|
|
|
|
public byte[] AppleRootCerts; // 数据取自 AppleTangle.Data();
|
2023-12-26 03:40:48 +00:00
|
|
|
|
|
|
|
|
|
|
#region Initialization
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 构建启动配置
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
2024-08-15 02:50:42 +00:00
|
|
|
|
[Obsolete("此方法将在下个版本中被废弃, 请直接使用 GuruSDKInitConfig.Builder 来进行初始化。 例如:GuruSDKInitConfig.Builder().SetIsBuyNoAds(true).Build()")]
|
2023-12-26 03:40:48 +00:00
|
|
|
|
public static GuruSDKInitConfig Build(
|
|
|
|
|
|
bool useCustomConsent = false,
|
|
|
|
|
|
bool autoLoadAds = true,
|
|
|
|
|
|
bool iapEnabled = true,
|
2024-08-15 02:50:42 +00:00
|
|
|
|
bool autoRecordFinishedLevels = false,
|
2024-03-31 10:36:47 +00:00
|
|
|
|
bool isBuyNoAds = false,
|
2024-08-14 07:23:44 +00:00
|
|
|
|
Action<string> onDeeplinkCallback = null,
|
2024-03-31 10:36:47 +00:00
|
|
|
|
string bannerBackgroundColor = "#00000000",
|
2024-01-18 09:03:53 +00:00
|
|
|
|
bool debugMode = false,
|
2023-12-26 03:40:48 +00:00
|
|
|
|
Dictionary<string, object> defaultRemoteData = null,
|
|
|
|
|
|
byte[] googleKeys = null,
|
|
|
|
|
|
byte[] appleRootCerts = null)
|
|
|
|
|
|
{
|
|
|
|
|
|
// 创建启动用参数
|
|
|
|
|
|
GuruSDKInitConfig config = new GuruSDKInitConfig()
|
|
|
|
|
|
{
|
|
|
|
|
|
UseCustomConsent = useCustomConsent,
|
|
|
|
|
|
AutoLoadWhenAdsReady = autoLoadAds,
|
|
|
|
|
|
IAPEnabled = iapEnabled,
|
|
|
|
|
|
AutoRecordFinishedLevels = autoRecordFinishedLevels,
|
2024-03-31 10:36:47 +00:00
|
|
|
|
IsBuyNoAds = isBuyNoAds,
|
|
|
|
|
|
BannerBackgroundColor = bannerBackgroundColor,
|
2024-01-18 09:03:53 +00:00
|
|
|
|
DebugMode = debugMode,
|
2023-12-26 03:40:48 +00:00
|
|
|
|
GoogleKeys = googleKeys,
|
|
|
|
|
|
AppleRootCerts = appleRootCerts,
|
2024-08-15 02:50:42 +00:00
|
|
|
|
OnAdjustDeeplinkCallback = onDeeplinkCallback,
|
2023-12-26 03:40:48 +00:00
|
|
|
|
DefaultRemoteData = defaultRemoteData ?? new Dictionary<string, object>(),
|
|
|
|
|
|
};
|
|
|
|
|
|
#if UNITY_EDITOR
|
2024-01-17 12:46:23 +00:00
|
|
|
|
config.DebugMode = true;
|
2023-12-26 03:40:48 +00:00
|
|
|
|
#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}");
|
2024-08-15 02:50:42 +00:00
|
|
|
|
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}");
|
2023-12-26 03:40:48 +00:00
|
|
|
|
sb.AppendLine($"\tIAPEnabled: {IAPEnabled}");
|
2024-08-15 02:50:42 +00:00
|
|
|
|
sb.AppendLine($"\tBannerBackgroundColor: {BannerBackgroundColor}");
|
|
|
|
|
|
sb.AppendLine($"\tCustomServiceKey: {CustomServiceKey}");
|
2023-12-26 03:40:48 +00:00
|
|
|
|
sb.AppendLine($"------- Custom init Config -------");
|
|
|
|
|
|
return sb.ToString();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
2024-08-15 02:50:42 +00:00
|
|
|
|
|
|
|
|
|
|
#region Builder
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 构造器
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public static GuruSDKInitConfigBuilder Builder() => new GuruSDKInitConfigBuilder();
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 构建器
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public class GuruSDKInitConfigBuilder
|
|
|
|
|
|
{
|
|
|
|
|
|
|
2024-08-15 03:17:52 +00:00
|
|
|
|
private readonly GuruSDKInitConfig _config = new GuruSDKInitConfig();
|
2024-08-15 02:50:42 +00:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 构建配置
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
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<string> 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<string, object> 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;
|
|
|
|
|
|
// }
|
2023-12-26 03:40:48 +00:00
|
|
|
|
}
|
2024-08-15 02:50:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|