统一的 Firebase 远程配置仅获取默认值而不是真实值

New*_*ton 6 c# unity-game-engine firebase unity5 firebase-remote-config

我正在尝试将 Firebase 远程配置实施到统一项目中。

这是唯一正在运行的脚本:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Firebase;
using Firebase.RemoteConfig;
using System;
using System.Threading.Tasks;

public class FirebaseAlt : MonoBehaviour
{
    private  DependencyStatus dependencyStatus = DependencyStatus.UnavailableOther;

    void Awake()
    {
        FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => {
            dependencyStatus = task.Result;
            if (dependencyStatus == DependencyStatus.Available)
            {
                 InitializeFirebase();
            }
            else
            {
                 Debug.LogError("Could not resolve all Firebase dependencies: " + dependencyStatus);
            }
         });
     }

     // Initialize remote config, and set the default values.
     void InitializeFirebase()
     {
          FetchData();
     }

     // Start a fetch request.
     public void FetchData()
     {
          Debug.Log("Fetching data...");
          // FetchAsync only fetches new data if the current data is older than the provided
          // timespan.  Otherwise it assumes the data is "recent enough", and does nothing.
          // By default the timespan is 12 hours, and for production apps, this is a good
          // number.  For this example though, it's set to a timespan of zero, so that
          // changes in the console will always show up immediately.
          Task fetchTask = FirebaseRemoteConfig.FetchAsync(TimeSpan.Zero);
          fetchTask.ContinueWith(FetchComplete);
      }

      void FetchComplete(Task fetchTask)
      {
           if (fetchTask.IsCanceled)
           {
               Debug.Log("Fetch canceled.");
           }
           else if (fetchTask.IsFaulted)
           {
               Debug.Log("Fetch encountered an error.");
           }
           else if (fetchTask.IsCompleted)
           {
               Debug.Log("Fetch completed successfully!");
           }

           var info = FirebaseRemoteConfig.Info;

           switch (info.LastFetchStatus)
           {
               case LastFetchStatus.Success:
                   FirebaseRemoteConfig.ActivateFetched();

                   Debug.Log(string.Format("Remote data loaded and ready (last fetch time {0}).", info.FetchTime));
                   string stop = FirebaseRemoteConfig.GetValue("stops").StringValue;
                   Debug.Log("Value: " + (string.IsNullOrEmpty(stop) ? "NA" : stop));

                   // Also tried this way, but then it doesn't enter the IF block
                   /*if (FirebaseRemoteConfig.ActivateFetched())
                   { 
                        Debug.Log(string.Format("Remote data loaded and ready (last fetch time {0}).", info.FetchTime));

                        string stop = FirebaseRemoteConfig.GetValue("stops").StringValue;
                        Debug.Log("Value: " + (string.IsNullOrEmpty(stop) ? "NA" : stop));
                   }*/
                   break;
               case LastFetchStatus.Failure:
                   switch (info.LastFetchFailureReason)
                   {
                       case FetchFailureReason.Error:
                             Debug.Log("Fetch failed for unknown reason");
                             break;
                       case FetchFailureReason.Throttled:
                             Debug.Log("Fetch throttled until " + info.ThrottledEndTime);
                             break;
                   }
                  break;
               case LastFetchStatus.Pending:
                  Debug.Log("Latest Fetch call still pending.");
                  break;
         }
     }
}
Run Code Online (Sandbox Code Playgroud)

当我运行此代码时,我得到了所有正确的响应

“正在获取数据……”、“获取成功!”

“远程数据已加载并准备就绪(上次获取时间为 1/1/1970 12:00:00 AM)。”

但值为空。

如果我查看键是什么,我会得到一个默认值列表(我在测试开始时放置了它,但删除了它),但没有我放入 firebase 控制台的任何新键(如 stops我键我试图展示)。

我尝试了几乎所有我能找到的解决方案,但无济于事。我有google-services.json(不知道是否与此相关),NDK 版本r13b。改为FirebaseRemoteConfig.Settings.IsDeveloperMode真。我还尝试等待一段时间(1 分钟)ActivateFetched(),看看它是否有任何改变。

ActivateFetched 上的 API 声明它返回:

如果有获取的配置并且它被激活,则为真。如果未找到 Fetched Config,或者 Fetched Config 已被激活,则为 false。

我怎样才能找到这个问题的根源?(为什么没有找到获取的配置。它存在于项目控制台中:/)