[英]Firebase doesn't show connected user
I'm learning to work with Firebase within Unity.我正在学习在 Unity 中使用 Firebase。
FirebaseApp.CheckAndFixDependenciesAsync().ContinueWithOnMainThread(task => {
FirebaseAnalytics.SetAnalyticsCollectionEnabled(true);
});
The app actually works.该应用程序确实有效。 It just doesn't show connected users.
它只是不显示连接的用户。
I went straight ahead and started logging data to the Real Time Data Base and it worked - data was added but it keeps saying "0 User Connections".我继续前进并开始将数据记录到实时数据库并且它有效 - 添加了数据但它一直说“0 用户连接”。
Is that a bug?那是一个错误吗?
The first thing to do is double check that the task
completed successfully.首先要做的是仔细检查
task
是否成功完成。 You can do this by saying:你可以这样说:
FirebaseApp.CheckAndFixDependenciesAsync().ContinueWithOnMainThread(task => {
if (task.Exception != null) {
Debug.LogError($"Task failed with {task.Exception}");
}
else if (task.Result != DependencyStatus.Available) {
Debug.LogError($"Firebase dependencies not available with {task.Result}");
}
else {
Debug.Log("Everything's good!");
FirebaseAnalytics.SetAnalyticsCollectionEnabled(true);
}
});
You'll want some way to listen to these messages on device, and you can sometimes get the Unity Console to track those.您需要通过某种方式在设备上收听这些消息,有时您可以让 Unity 控制台跟踪这些消息。 But these days I like to install the Android Logcat plugin.
不过最近喜欢安装Android Logcat插件。 You can find it in the Package Manager built into Unity:
您可以在 Unity 内置的 Package Manager 中找到它:
It'll give you this cool window under Window/Analysis/Android Logcat:它会在 Window/Analysis/Android Logcat 下给你这个很酷的 window:
And usually automatically hooks up to any game I run with the "Build & Run" button in Unity.通常会自动连接到我使用 Unity 中的“Build & Run”按钮运行的任何游戏。
This will give you a ton of useful information about your game and perhaps shed a little more light on what's going on if you either hadn't been seeing the Unity logs or had been running adb logcat
from the command line.这将为您提供有关您的游戏的大量有用信息,并且如果您没有看到 Unity 日志或一直在从命令行运行
adb logcat
,则可能会更清楚地了解正在发生的事情。
If you don't see any helpful logs there, there's a button in that logcat window called "Open Terminal".如果您在那里没有看到任何有用的日志,则该 logcat window 中有一个名为“打开终端”的按钮。 The claim is that it will open a terminal with adb in the $PATH so you can run android commands (in my own testing, the window appeared behind Unity, so I didn't think it was working. Then using
which adb
it still showed my system install of adb.).声称它会在 $PATH 中打开一个带有 adb 的终端,这样你就可以运行 android 命令(在我自己的测试中,window 出现在 Unity后面,所以我认为它不起作用。然后使用
which adb
它仍然显示我的系统安装了 adb。)。
With this open, follow the instructions for debugging analytics on Android .打开后,按照Android 上的调试分析说明进行操作。 You'll want to type
adb shell setprop debug.firebase.analytics.app <package_name>
where <package_name>
would be whatever your game's package name is (in my screenshot above, it's com.Firebase.PopsiclePlatformer
).您需要键入
adb shell setprop debug.firebase.analytics.app <package_name>
其中<package_name>
可以是您游戏的 package 名称(在我上面的屏幕截图中,它是com.Firebase.PopsiclePlatformer
)。
Then you can open "Debug View" in the Firebase Console and see events in near real time:然后您可以在 Firebase 控制台中打开“调试视图”并近乎实时地查看事件:
I didn't include these steps in my video because it was difficult to embed both iOS and Android instructions in a timely manner, it should typically just work although Analytics doesn't guarantee realtime event reporting, and the focus wasn't on Analytics.我没有在我的视频中包含这些步骤,因为很难及时嵌入 iOS 和 Android 指令,它通常应该可以正常工作,尽管 Analytics 不保证实时事件报告,而且重点不在 Analytics 上。 I'm looking at making an updated thing just for Analytics, so I'm really curious if all of this helps you!
我正在考虑为 Analytics 做一个更新的东西,所以我真的很好奇这一切是否对你有帮助!
There are a couple of other things to check:还有一些其他的事情要检查:
--Patrick ——帕特里克
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.