[英]Unity Firebase Invites throws exception ApplicationException: internal::IsInitialized()
I'm trying to add Firebase Invites to my Unity game.我正在尝试将 Firebase 邀请添加到我的 Unity 游戏中。 I've followed all the tutorial steps and have set up seems like everything.我已经按照所有的教程步骤进行了设置,一切似乎都已完成。 But when I try to run the code from tutorial to send an invite, I'm getting an exception:但是当我尝试运行教程中的代码来发送邀请时,我遇到了一个异常:
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)
...
The code is:代码是:
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);
}
I use:我用:
Any help would be highly appreciated!任何帮助将不胜感激!
I think I found a solution.我想我找到了解决办法。
That error occurs when use "SendEvent()" before firebase initialized.在 firebase 初始化之前使用“SendEvent()”时会发生该错误。
I solved error by below code.我通过以下代码解决了错误。
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);
});
}
Enter your first "SendEvent" in the CheckAndFixDependenciesAsync().在 CheckAndFixDependenciesAsync() 中输入您的第一个“SendEvent”。
Hope this was helpful.希望这对您有所帮助。
After I finded and installed Older version of firebase(6.15.2), The older version of firebase showed me a helpful error message...在我找到并安装旧版本的 firebase(6.15.2) 之后,旧版本的 firebase 向我显示了一条有用的错误消息......
"don't call firebase functions before check dependencies has finished" “在检查依赖项完成之前不要调用 firebase 函数”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.