firebase / firebase-unity-sdk

The Firebase SDK for Unity
http://firebase.google.com
Apache License 2.0
229 stars 38 forks source link

Unable to use Firebase.Functions in my Assembly but other imports work just fine #814

Closed chriswalz closed 1 year ago

chriswalz commented 1 year ago

[REQUIRED] Please fill in the following fields:

[REQUIRED] Please describe the issue here:

Firebase.Functions can't be imported... image

Error: "The type or namespace name 'Functions' does not exist in the namespace 'Firebase' (are you missing an assembly reference?)" using Firebase.Functions;

Steps to reproduce:

  1. Install firebase sdk using UPM
  2. create an Assembly
  3. Put a script "TestFirebase.cs" in the assembly folder
  4. Import Firebase App and Firestore will work fine BUT Firebase.Functions import will NOT be recognized

This is likely due to a bad assembly setup for functions in the Firebase SDK

Relevant Code:

    Firebase.FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task =>
    {
        var dependencyStatus = task.Result;
        if (dependencyStatus == Firebase.DependencyStatus.Available)
        {
            // Create and hold a reference to your FirebaseApp,
            // where app is a Firebase.FirebaseApp property of your application class.
            app = Firebase.FirebaseApp.DefaultInstance;
            db = FirebaseFirestore.GetInstance(app);

            Firebase.Functions.FirebaseFunctions.GetInstance("us-central1").GetHttpsCallable("helloWorld").CallAsync().ContinueWith((task) =>
            {
                if (task.IsFaulted)
                {
                    Debug.Log("Error: " + task.Exception);
                }
                else
                {
                    Debug.Log("Result: " + task.Result.Data);
                }
            });

        }
        else
        {
            Debug.LogError(System.String.Format("FirebaseManager: Could not resolve all Firebase dependencies: {0}", dependencyStatus));
            // Firebase Unity SDK is not safe to use here.
        }
    });
chriswalz commented 1 year ago

It's working now, I'm not sure why.. restarting my computer fixed it.