Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Multiple Firebase products together? / no app has been configured yet / Delayed Analytics Realtime #1162

Closed
gokhancnr opened this issue Dec 12, 2024 · 3 comments

Comments

@gokhancnr
Copy link

What is your question?

Hi there,

I'm using;

  1. Analytics
  2. Crashlytics
  3. Cloud Messaging
  4. Remote Config

all together in my game:

FirebaseInitController:

        FirebaseApp.CheckAndFixDependenciesAsync().ContinueWithOnMainThread(task =>
        {
            DependencyStatus dependencyStatus = task.Result;

            if (dependencyStatus == DependencyStatus.Available)
            {
                // Create and hold a reference to your FirebaseApp,
                // where app is a Firebase.FirebaseApp property of your application class.
                FirebaseApp app = FirebaseApp.DefaultInstance;

                initialized = true;

                FirebaseAnalyticsController.Instance.InitializeFirebaseAnalytics();

                FirebaseCrashlyticsController.Instance.InitializeFirebaseCrashlytics();

                FirebaseRemoteConfigController.Instance.InitializeFirebaseRemoteConfig();

                FirebaseCloudMessagingController.Instance.InitializeFirebaseCloudMessaging();

                // Set a flag here to indicate whether Firebase is ready to use by your app.
            }

            else
            {
                Debug.LogError($"Could not resolve all Firebase dependencies: {dependencyStatus}");
                // Firebase Unity SDK is not safe to use here.
            }
        });

FirebaseAnalyticsController.Instance.InitializeFirebaseAnalytics():

FirebaseAnalytics.SetAnalyticsCollectionEnabled(true);

FirebaseCrashlyticsController.Instance.InitializeFirebaseCrashlytics():

Crashlytics.ReportUncaughtExceptionsAsFatal = true;

FirebaseRemoteConfigController.Instance.InitializeFirebaseRemoteConfig():

       FirebaseRemoteConfig.DefaultInstance.SetDefaultsAsync(defaults).ContinueWithOnMainThread(task =>
        {
            //Debug.Log("Firebase RemoteConfig configured and ready!");

            ConfigSettings configSettings = new ConfigSettings
            {
                FetchTimeoutInMilliseconds = 0, //2000

                MinimumFetchIntervalInMilliseconds = 0
            };

            FirebaseRemoteConfig.DefaultInstance.SetConfigSettingsAsync(configSettings).ContinueWithOnMainThread(
                setting =>
                {
                    FetchDataAsync();
                });
        });

FirebaseCloudMessagingController.Instance.InitializeFirebaseCloudMessaging():

        FirebaseMessaging.MessageReceived += OnMessageReceived;

        FirebaseMessaging.TokenReceived += OnTokenReceived;

        //Debug.Log("Firebase Messaging Initialized");

        // This will display the prompt to request permission to receive
        // notifications if the prompt has not already been displayed before. (If
        // the user already responded to the prompt, thier decision is cached by
        // the OS and can be changed in the OS settings).
        FirebaseMessaging.RequestPermissionAsync().ContinueWithOnMainThread(task =>
        {
            LogTaskCompletion(task, "RequestPermissionAsync");
        });
  1. My first question is; is this methodology is ok to use when multiple Firebase products are together in a project?

  2. When I build on my iPhone logs are saying:

image

  1. And the last question is when I open my app I can not see my realtime Analytics data suddenly. How should I achieve to see my realtime analytics as soon as the application is opened?

Firebase Unity SDK Version

12.4.1

Unity editor version

6000.0.30f1

Installation Method

.unitypackage

Problematic Firebase Component(s)

Analytics, Crashlytics, Messaging, Remote Config

Other Firebase Component(s) in use

No response

Additional SDKs you are using

No response

Targeted Platform(s)

Apple Platforms, Android

Unity editor platform

Mac, Windows

Scripting Runtime

IL2CPP

Release Distribution Type

Pre-built SDK from https://firebase.google.com/download/unity

@google-oss-bot
Copy link

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

@gokhancnr
Copy link
Author

anybody?

@argzdev
Copy link

argzdev commented Jan 23, 2025

Hey @gokhancnr, sorry for the delayed response here.

My first question is; is this methodology is ok to use when multiple Firebase products are together in a project?

Yes, adding multiple Firebase products together should work normally. Looking through your source code, you've pretty much set it up correctly.

When I build on my iPhone logs are saying:

This error log is expected. Firebase is not yet configured at app start, and only fully finishes setting up once FirebaseApp.CheckAndFixDependenciesAsync() has finished. That said, even if this error shows up, you would see that Firebase will work correctly.

And the last question is when I open my app I can not see my realtime Analytics data suddenly. How should I achieve to see my realtime analytics as soon as the application is opened?

Firebase Analytics does not have real time events. Normally, our events are sent at intervals of a few hours ranging from an hour all the way up to 24 hours. We do not offer real time analytics to avoid heavy data load transfer between client and server.

We do offer near real-time events only for testing, if you are interested, you may check out our documentations here.

I believe all your questions have been answered, so I'll go ahead and close this thread. Feel free to post back here if you have further questions. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants