我试图将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);
}
我用:
任何帮助都将受到高度赞赏!
答案 0 :(得分:0)
我想我找到了解决方法。
在初始化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函数”