-
Notifications
You must be signed in to change notification settings - Fork 52
Description
- Unity editor version: 2020.3.45f1
- Firebase Unity SDK version: 11.0.0
- Source you installed the SDK: .unitypackage
- Problematic Firebase Component: Auth
- Other Firebase Components in use: Analytics, Crashlytics, RemoteConfig, Database, Storage
- Additional SDKs you are using: None
- Platform you are using the Unity editor on: Windows
- Platform you are targeting: Android
- Scripting Runtime: IL2CPP
- Pre-built SDK from the website or open-source from this repo: None
Hi, I have a question regarding Phone Authentication on Android.
We have 5 Android games, each one has its own Firebase application configured in Firebase Console.
In each game, we imported the google-services.json file. We use Firebase Analytics, Crashlytics, RemoteConfig, Database, and Storage services by Firebase.FirebaseApp.DefaultInstance (which is configured via the google-services.json file).
Everything related to these services mentioned above works as expected.
Regarding the authentication, we created a 6th Firebase application in Firebase Console that will be used by all 5 games. This is because we want the authentication to be cross-apps (users can log in to the same account in all the games).
To use this FirebaseApp in Unity, we create a FirebaseApp like this: Firebase.FirebaseApp.Create(AppOptions, "OurAuthApp").
This worked fine with the email verification. But there is a problem with the phone authentication.
Here is the code that causes the error:
` Firebase.Auth.PhoneAuthOptions phoneOptions = new Firebase.Auth.PhoneAuthOptions {
PhoneNumber = phoneNumber,
TimeoutInMilliseconds = 1000 * 60 * 3,
ForceResendingToken = null
};
PhoneAuth.VerifyPhoneNumber(phoneOptions,
verificationCompleted: (credential) => {
// Auto-sms-retrieval or instant validation has succeeded (Android only).
// There is no need to input the verification code.
// `credential` can be used instead of calling GetCredential().
},
verificationFailed: (error) => {
Debug.Log("## Here is the error printed");
Debug.Log(error);
// The verification code was not sent.
// `error` contains a human readable explanation of the problem.
},
codeSent: (id, token) => {
// Verification code was successfully sent via SMS.
// `id` contains the verification id that will need to passed in with
// the code from the user when calling GetCredential().
// `token` can be used if the user requests the code be sent again, to
// tie the two requests together.
// Firebase user has been created.
},
codeAutoRetrievalTimeOut: (id) => {
// Called when the auto-sms-retrieval has timed out, based on the given
// timeout parameter.
// `id` contains the verification id of the request that timed out.
}
);
`
This is the "human readable" error we get (it calls verificationFailed):
VerifyPhoneNumber: builder faild to create PhoneAuhtOptions <>c__DisplayClass37_0:<PhoneSignUp>b__1(String) Firebase.Auth.VerificationFailed:Invoke(String) Firebase.Auth.<>c__DisplayClass12_0:<VerificationFailedHandler>b__0() System.Action:Invoke() Firebase.ExceptionAggregator:Wrap(Action) Firebase.AppUtilPINVOKE:PollCallbacks() Firebase.AppUtil:PollCallbacks() Firebase.Platform.FirebaseHandler:Update()
By the way, on iOS everything works fine (including the phone authentication so the problem is only on Android).
How can I see more useful and detailed logs, the "human readable" error above isn't enough to understand what is missing.
Any ideas or potential solutions?
Thanks!