Unity Firebase Invites 抛出异常ApplicationException: internal::IsInitialized()

Unity Firebase Invites throws exception ApplicationException: internal::IsInitialized()

我正在尝试将 Firebase 邀请添加到我的 Unity 游戏中。我已经按照所有的教程步骤进行了设置,一切似乎都已完成。但是,当我尝试 运行 教程中的代码发送邀请时,出现异常:

ApplicationException: internal::IsInitialized()
 at Firebase.FutureBase.status ()
 at Firebase.Invites.SendInviteFuture.GetTask (Firebase.Invites.SendInviteFuture fu)
 at Firebase.Invites.FirebaseInvites.SendInviteAsync (Firebase.Invites.Invite invite)
...

密码是:

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

void InitializeFirebase()
{
    Firebase.Invites.FirebaseInvites.InviteReceived += OnInviteReceived;
    Firebase.Invites.FirebaseInvites.InviteNotReceived += OnInviteNotReceived;
    Firebase.Invites.FirebaseInvites.ErrorReceived += OnErrorReceived;
}

public void ShowInviteBox(System.Action<bool> callback)
{
  var invite = new Firebase.Invites.Invite() {
    TitleText = "Invites Test App",
    MessageText = "Please try my app! It's awesome.",
    CallToActionText = "Download it for FREE",
    DeepLinkUrl = new System.Uri("http://google.com/abc")
  };
  Firebase.Invites.FirebaseInvites.SendInviteAsync(invite).ContinueWith(HandleSentInvite);
}

我使用:

非常感谢任何帮助!

我想我找到了解决办法。

在 firebase 初始化之前使用“SendEvent()”时会发生该错误。

我通过以下代码解决了错误。

private void InitializeFirebase()
{
    Debug.Log("FirebaseManager : Enabling data collection.");
    FirebaseAnalytics.SetAnalyticsCollectionEnabled(true);

    Debug.Log("FirebaseManager : Set user properties.");
    // Set the user's sign up method.
    FirebaseAnalytics.SetUserProperty(
      FirebaseAnalytics.UserPropertySignUpMethod,
      "Google");
    // Set the user ID.
    FirebaseAnalytics.SetUserId("uber_user_510");
    // Set default session duration values.
    FirebaseAnalytics.SetMinimumSessionDuration(new TimeSpan(0, 0, 10));
    FirebaseAnalytics.SetSessionTimeoutDuration(new TimeSpan(0, 30, 0));

    //THIS IS SOLUTION!!!!
    Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => 
    {
        FirebaseAnalytics.LogEvent(FirebaseAnalytics.EventLogin);
    });
}

在 CheckAndFixDependenciesAsync() 中输入您的第一个“SendEvent”。

希望这对您有所帮助。


在我找到并安装旧版本的 firebase(6.15.2) 后, 旧版本的 firebase 向我显示了一条有用的错误消息...

“在检查依赖项完成之前不要调用 firebase 函数”