update: 调整IAP初始化顺序

feature/item_system
胡宇飞 2023-12-28 16:33:12 +08:00
parent a4bb381856
commit 0f4433b493
2 changed files with 17 additions and 19 deletions

View File

@ -36,6 +36,7 @@ namespace Guru
ad_settings.moloco_ids_ios.Length > 0; ad_settings.moloco_ids_ios.Length > 0;
public bool IsIAPEnabled() => app_settings != null && app_settings.enable_iap public bool IsIAPEnabled() => app_settings != null && app_settings.enable_iap
&& products != null && products.Length > 0; && products != null && products.Length > 0;
public bool IsKeywordsEnabled() => app_settings != null && app_settings.enable_keywords;
//-------------------------------- 配置检测 ------------------------------- //-------------------------------- 配置检测 -------------------------------
} }
@ -52,7 +53,7 @@ namespace Guru
public string ios_store; public string ios_store;
public int token_vaild_time = 604800; public int token_vaild_time = 604800;
public int level_end_success_num = 50; public int level_end_success_num = 50;
public bool use_keywords = true; public bool enable_keywords = true;
public bool enable_firebase = true; public bool enable_firebase = true;
public bool enable_facebook = true; public bool enable_facebook = true;
public bool enable_adjust = true; public bool enable_adjust = true;

View File

@ -1,9 +1,8 @@
using System.Collections;
namespace Guru namespace Guru
{ {
using UnityEngine; using UnityEngine;
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
@ -121,25 +120,18 @@ namespace Guru
/// </summary> /// </summary>
private void OnFirebaseReady() private void OnFirebaseReady()
{ {
LogI($"--- Firebase complete ---");
if (_appServicesConfig.IsIAPEnabled())
{
// LogI($"--- #2 Init IAP ---");
InitIAP(_initConfig.GoogleKeys, _initConfig.AppleRootCerts); // 初始化IAP
}
if (!InitConfig.UseCustomConsent) if (!InitConfig.UseCustomConsent)
{ {
// LogI($"--- #3 Start Consent Flow ---"); // LogI($"--- #3 Start Consent Flow ---");
StartConsentFlow(); StartConsentFlow();
} }
if(!string.IsNullOrEmpty(IPMConfig.IPM_UID)) SetUID(IPMConfig.IPM_UID);
// 开始Remote Manager初始化 // 开始Remote Manager初始化
RemoteConfigManager.Init(BuildDefaultRemoteData(_initConfig.DefaultRemoteData)); RemoteConfigManager.Init(BuildDefaultRemoteData(_initConfig.DefaultRemoteData));
RemoteConfigManager.OnFetchCompleted += OnFetchRemoteCallback; RemoteConfigManager.OnFetchCompleted += OnFetchRemoteCallback;
if(!string.IsNullOrEmpty(IPMConfig.IPM_UID)) SetUID(IPMConfig.IPM_UID);
// 根据上次的云控配置来初始化参数 // 根据上次的云控配置来初始化参数
SetupServicesConfig(); SetupServicesConfig();
@ -181,14 +173,14 @@ namespace Guru
private void SetupServicesConfig() private void SetupServicesConfig()
{ {
bool useKeywords = true; bool useKeywords = true;
bool useIAP = true;
var guruSettings = GuruSettings.Instance; var guruSettings = GuruSettings.Instance;
var services = GetRemoteServicesConfig(); var services = GetRemoteServicesConfig();
if (services != null) if (services != null)
{ {
_appServicesConfig = services; _appServicesConfig = services;
useKeywords = _appServicesConfig.app_settings.use_keywords; useKeywords = _appServicesConfig.IsKeywordsEnabled();
if (null != guruSettings) if (null != guruSettings)
{ {
@ -201,12 +193,17 @@ namespace Guru
guruSettings.UpdateAdjustEvents(_appServicesConfig.adjust_settings.events); guruSettings.UpdateAdjustEvents(_appServicesConfig.adjust_settings.events);
} }
} }
useIAP = _appServicesConfig.IsIAPEnabled();
}
AdjustService.StartService();
if(useIAP) {
InitIAP(_initConfig.GoogleKeys, _initConfig.AppleRootCerts); // 初始化IAP
} }
if(useKeywords) KeywordsManager.Install(Model.IsIAPUser, Model.SuccessLevelCount); // 启动Keyword管理器 if(useKeywords) {
KeywordsManager.Install(Model.IsIAPUser, Model.SuccessLevelCount); // 启动Keyword管理器
AdjustService.StartService(); }
} }