2

I am working on a game that requires user's phone verification to play the game. I am using Firebase Authentication. I have also added SHA keys to Firebase Project.I checked out some tutorials on youtube and found out that they are enabling android device verification API from Google Cloud but by 31 jan 2023 Google has DEPRECATED it and now we have to use Play Integrity API. Now i don't know if i am right or not but i guess i can't use this API if my game is not published on Google Play Store. Please Help As i am not publishing my game to Play Store. This Is My Code

using Firebase;
using Firebase.Auth;
using TMPro;
using UnityEngine;

public class FIrebaseAuth : MonoBehaviour
{
    public TMP_InputField phoneNumberInputField;

    private FirebaseAuth auth;

    private uint timeOut = 60 * 1000;
    private void Start()
    {
        FirebaseApp.CheckAndFixDependenciesAsync().ContinueWith(task =>
        {
            if (task.Exception != null)
            {
                Debug.LogError("Failed to initialize Firebase: " + task.Exception);
                return;
            }

            auth = FirebaseAuth.DefaultInstance;
        });
    }

    public void VerifyPhoneNumber()
    {
        string phoneNumber = phoneNumberInputField.text;

        PhoneAuthProvider provider = PhoneAuthProvider.GetInstance(auth);
        provider.VerifyPhoneNumber(phoneNumber, timeOut, null, verificationCompleted: (credential) =>
        {
            // Auto-sms-retrieval or instant verification is successful.
            // Use credential to sign in the user.
        }, verificationFailed: (error) =>
        {
            // The verification process has failed.
            // Display an error message to the user.
            Debug.Log("send failed");
        }, codeSent: (id, token) =>
        {
            // Verification code was successfully sent via SMS.
            // Show the code input field to the user.
            Debug.Log("Code Sent");
        }, codeAutoRetrievalTimeOut: (id) =>
        {
            // Called when auto-sms-retrieval timed out and provides a way to handle this scenario.
        });
    }
}

I enabled Play Integrity from Google Could to give it a try but it didn't worked.

1 Answers1

0

You are correct that Play Integrity requires being distributed through Google Play.

That said, authentication and phone verification can be done without being on Google Play.

Try running the project with Play Integrity disabled or try to replicate the issue using the Firebase Auth test app.

Joe Spiro
  • 89
  • 3