我正在使用Unity构建一个小型测试应用程序,以学习Firebase和动态链接。我已经导入了Dynamic Links SDK和google-services json文件。
在我的脚本中,我试图订阅事件“ DynamicLinkReceived”,但添加了这行代码
DynamicLinks.DynamicLinkReceived += ReceivedDeepLink;
导致Android应用在加载时挂在黑屏上。当我在Unity中运行该应用程序时,它不会挂起或产生任何错误。这是应该在该事件上调用的方法:
void ReceivedDeepLink(object sender, EventArgs args)
{
var dynamicLinkEventArgs = args as ReceivedDynamicLinkEventArgs;
Debug.LogFormat("Received dynamic link {0}",
dynamicLinkEventArgs.ReceivedDynamicLink.Url.OriginalString);
inputBottom.text = dynamicLinkEventArgs.ReceivedDynamicLink.Url.OriginalString;
}
答案 0 :(得分:0)
发生这种情况是因为您致电
DynamicLinks.DynamicLinkReceived += ReceivedDeepLink;
CheckAndFixDependenciesAsync()
仍在进行中。
您可以将火力基础更新为5.2.1,在这种情况下,它们已经引发异常。 https://firebase.google.com/support/release-notes/unity#5.1.0
首先初始化firebase,并且如果(dependencyStatus == DependencyStatus.Available)
您可以订阅DynamicLink
void InitializeFirebaseAndStart() {
FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task => {
dependencyStatus = task.Result;
if (dependencyStatus == DependencyStatus.Available) {
DynamicLinks.DynamicLinkReceived += ReceivedDeepLink;
} else {
Debug.LogError(
"Could not resolve all Firebase dependencies: " + dependencyStatus);
}
});
}