fix: 修复 GuruServices 在使用 CustomKey 的时候, 由于首次加载无法获取报空的问题

deeplink
胡宇飞 2024-03-19 17:33:37 +08:00
parent abf252360c
commit d70c6eff8e
2 changed files with 20 additions and 4 deletions

View File

@ -88,17 +88,19 @@ namespace Guru
/// </summary>
private void StartConsentFlow()
{
if (!_adServiceHasStarted)
float time = 1;
if (!_adServiceHasStarted && _appServicesConfig != null)
{
var time = _appServicesConfig.IsAdsCompliance() ? 10 : 1f; // 启动合规判定后, 延迟最多 10 秒后启动广告
Delay(time, AdServiceHandler); // 广告延迟启动
time = _appServicesConfig.IsAdsCompliance() ? 10 : 1f; // 启动合规判定后, 延迟最多 10 秒后启动广告
}
Delay(time, AdServiceHandler); // 广告延迟启动
if (_hasConsentCalled) return;
_hasConsentCalled = true;
bool enableCountryCheck = false;
string dmaMapRule = "";
if (_appServicesConfig != null && _appServicesConfig.parameters != null)
{
enableCountryCheck = _appServicesConfig.DMACountryCheck();

View File

@ -342,16 +342,30 @@ namespace Guru
/// <returns></returns>
private GuruServicesConfig GetRemoteServicesConfig()
{
string defaultJson = GetRemoteString(ServicesConfigKey);
bool useCustomKey = false;
string key = ServicesConfigKey;
if (!string.IsNullOrEmpty(_initConfig.CustomServiceKey))
{
key = _initConfig.CustomServiceKey;
useCustomKey = true;
}
var json = GetRemoteString(key);
var json = GetRemoteString(key); // Cloud cached data
if (string.IsNullOrEmpty(json) && useCustomKey && !string.IsNullOrEmpty(defaultJson))
{
// No remote data fetched from cloud, should use default values
json = defaultJson;
Debug.Log($"{Tag} --- No remote data found with: {key} -> Using default key {ServicesConfigKey} and local data!!!");
}
if (!string.IsNullOrEmpty(json))
{
return JsonParser.ToObject<GuruServicesConfig>(json);
}
return null;
}