简体   繁体   English

Firebase 不显示已连接的用户

[英]Firebase doesn't show connected user

I'm learning to work with Firebase within Unity.我正在学习在 Unity 中使用 Firebase。

1. What I've done so far - 1.到目前为止我做了什么 -

  • 1.1 Created a Firebase and Unity project 1.1 创建了一个Firebase和Unity工程
  • 1.2 copied the json file into Assets folder 1.2 复制json文件到Assets文件夹
  • 1.3 imported Firebase packages 1.3导入Firebase个包
  • 1.4 downloaded jdk-8 and created JAVA_HOME variable 1.4 下载jdk-8并创建JAVA_HOME变量
  • 1.5 Created a c# script and put it into a gameobject (from the Firebase tutorial) 1.5 创建一个 c# 脚本并将其放入游戏对象(来自 Firebase 教程)
 FirebaseApp.CheckAndFixDependenciesAsync().ContinueWithOnMainThread(task => {
                FirebaseAnalytics.SetAnalyticsCollectionEnabled(true);

});
  • 1.6 switched to Android environment and built with result "SUCCESSFUL" - with no errors whatsoever. 1.6 切换到 Android 环境并构建结果为“成功”——没有任何错误。

2. The issue - 2.问题-

  • 2.1 I logged into my project on firebase and ran the code (from pc on Unity) and on my Android device, but firebase doesn't show any users connected:( (waiting for analytics). 2.1 我在 firebase 上登录我的项目并运行代码(从 Unity 上的电脑)和我的 Android 设备,但 firebase 没有显示任何连接的用户:((等待分析)。
  • 2.2 Firebase What am I doing wrong? 2.2 Firebase我做错了什么?

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 中找到它: 选择了 Android Logcat 的包管理器。搜索是“android”

It'll give you this cool window under Window/Analysis/Android Logcat:它会在 Window/Analysis/Android Logcat 下给你这个很酷的 window: Unity 中的 Android Logcat 窗口

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 控制台中打开“调试视图”并近乎实时地查看事件: 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:还有一些其他的事情要检查:

  • You might want to make sure you hooked up Google Analytics (this wasn't a thing when I recorded my video), but I don't think you could get the linked screenshot if you did.您可能想确保连接了 Google Analytics(我录制视频时这不是问题),但我认为如果您这样做了,您将无法获得链接的屏幕截图。
  • You may also have to run "Force Resolve" from the External Dependency Manager, but that will be much more obvious if you have good logging going:您可能还必须从外部依赖管理器运行“强制解决”,但如果您有良好的日志记录,那将更加明显: 选择了 Assets/External Dependency Manager/Android/Force Resolve 的屏幕截图

--Patrick ——帕特里克

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 连接到用户的唯一节点 - Firebase 实时数据库 - Unique node connected to user - Firebase Realtime Database React Native Firebase 注销 function 在根据用户类型登录后不起作用 - React Native Firebase logout function doesn't work after login based on user type Facebook 主电子邮件更改后,Firebase 不会更新 Facebook 用户的电子邮件 - Firebase doesn't update email of Facebook user after Facebook primary email changes iOS 推送通知不适用于 Firebase - iOS Push Notifications doesn't work with Firebase firebase setCustomUserClaims 执行不会在模拟器中结束 - firebase setCustomUserClaims execution doesn't end in emulator Firebase 分析在真实设备中不起作用 - Firebase Analytics doesn't work in real devices Firebase 在 Android Studio 模拟器上不起作用 - Firebase doesn't work on Android Studio Emulator Firebase 功能:与 Algolia 同步不起作用 - Firebase functions: sync with Algolia doesn't work 在 flutter 形式 firebase 中显示当前用户数据的任何方法? - any method to show current user data in flutter form firebase? 离开 Firebase 中的项目但没有该项目的所有权 - Leaving a project in Firebase but doesn't have the ownership for the project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM