From Firebase, user_pseudo_id
is logged to Bigquery. I am trying to get the matching value to those user_pseudo_ids from the unity project that uses Firebase SDK. FirebaseAnalytics.GetAnalyticsInstanceIdAsync()
does not seem to execute in Android devices.
I tried GetAnalyticsInstanceIdAsync
using FirebaseAnalytics
as follows:
public Task<string> DisplayAnalyticsInstanceId()
{
return FirebaseAnalytics.GetAnalyticsInstanceIdAsync().ContinueWithOnMainThread(task =>
{
if (task.IsCanceled)
{
Debug.Log("App instance ID fetch was canceled.");
}
else if (task.IsFaulted)
{
Debug.Log(String.Format("Encounted an error fetching app instance ID {0}",
task.Exception.ToString()));
}
else if (task.IsCompleted)
{
Debug.Log(String.Format("App instance ID: {0}", task.Result));
}
string user_pseudo_id = task.Result;
return task;
}).Unwrap();
}
When I run the project on Windows, I get App instance ID: FakeAnalyticsInstanceId0
in the debug log. However, when I build as an apk and test it on my andriod device it does nothing as if public Task<string> DisplayAnalyticsInstanceId()
never executes. I tried displaying the result on the screen of the phone which does not show up. Any suggestions?
2
Answers
I do get your problem, check your Android manifest, Past Project Package name in to the Unity3d Build Settings and in manifest from firebase project console and it will work in Android too.
we can do that easily with user Authentication and checking every user id that they are using Firebase or not by simply adding of user in realtime fireabse Database, which also work offline too.
Do let me know if you need more help, Thank you
I red your issue carefully.
It seems that you are facing an issue with executing FirebaseAnalytics.GetAnalyticsInstanceIdAsync() in your Unity project on Android devices. Here are a few suggestions to help you troubleshoot the problem:
Check Firebase initialization: Ensure that you have properly initialized Firebase in your Unity project. Make sure you have followed the necessary steps to integrate Firebase SDK into your Unity project and that the Firebase Analytics module is correctly set up.
Verify device connectivity: Ensure that your Android device has an active internet connection. Firebase Analytics requires an internet connection to fetch the app instance ID.
Check for error messages: Review the Android device logs to see if there are any error messages related to Firebase or the analytics instance ID retrieval. You can use Android Debug Bridge (ADB) or logcat to view the logs.
Update Firebase SDK: Make sure you are using the latest version of the Firebase SDK for Unity. Outdated versions may have compatibility issues with certain devices or operating systems.
Test on different Android devices: Try running your Unity project on multiple Android devices to see if the issue is specific to a particular device or if it occurs across different devices. This can help identify if the problem is device-specific.
Test on a physical device: If you have been testing on an emulator, try running the project on a physical Android device. Emulators may have limitations or differences that could affect the execution of Firebase Analytics.
Verify permissions: Ensure that your Android manifest file includes the necessary permissions for Firebase Analytics. The required permission is INTERNET.
By following these steps, you should be able to identify and resolve the issue with executing FirebaseAnalytics.GetAnalyticsInstanceIdAsync() in your Unity project on Android devices.
If it not works or you have some questions in my solution, please let me know.