androidunity-game-enginefirebase-app-checkgoogle-play-integrity-api

How to fix "The name 'PlayIntegrityAppCheckProviderFactory' does not exist in the current context" when using Play Integrity with Unity?


I'm facing an issue when i try to build my app by using play integrity in firebase library on unity. here is my class that work in debug and compile also if i remove the android code with play integrity but not compile when i put it :

using UnityEngine;
using Firebase;
using Firebase.Extensions;
using Firebase.AppCheck;

public class FirebaseInit : MonoBehaviour
{
    public bool isDebugMode = false;
    private const string debugToken = "xxxxxxxxxxxxxxxxxxxxxxx";

    void Start()
    {
        if (isDebugMode)
        {
            DebugAppCheckProviderFactory.Instance.SetDebugToken(debugToken);
            FirebaseAppCheck.SetAppCheckProviderFactory(DebugAppCheckProviderFactory.Instance);
        } else
        {
        #if UNITY_ANDROID && !UNITY_EDITOR
            FirebaseAppCheck.SetAppCheckProviderFactory(PlayIntegrityAppCheckProviderFactory.Instance);
        #endif
        }

        FirebaseApp.CheckAndFixDependenciesAsync().ContinueWithOnMainThread(task =>
            {
                if (task.Result == DependencyStatus.Available)
                {
                    Debug.Log(isDebugMode
                        ? "Firebase + App Check initialisé avec Debug Provider"
                        : "Firebase initialisé (App Check par défaut – Play Integrity en prod)");
                }
                else
                {
                    Debug.LogError("Firebase non initialisé : " + task.Result);
                }
            });
    }
}

and here is the error :

Assets\Scripts\FirebaseInit.cs(20,57): error CS0103: The name 'PlayIntegrityAppCheckProviderFactory' does not exist in the current context

I have the play integrity dependency 18.0.0 but it still not work.


Solution

  • I think, you should use

    PlayIntegrityProviderFactory.Instance
    

    Not PlayIntegrityAppCheckProviderFactory.Instance. Or another one. I don`t know what you need...

    enter image description here

    https://firebase.google.com/docs/app-check/unity/default-providers