firebase-unity-sdk
firebase-unity-sdk copied to clipboard
Allow to provide the ClientId to Firebase.AppOptions
[REQUIRED] Please fill in the following fields:
- Unity editor version: 2019.3.12f1
- Firebase Unity SDK version: 6.15.2
- Source you installed the SDK: Unity Package Manager (.unitypackage or Unity Package Manager)
- Problematic Firebase Component: Auth (Auth, Database, etc.)
- Other Firebase Components in use: Firestore, Storage, Cloud Functions, Analytics, Crashlytics (Auth, Database, etc.)
- Additional SDKs you are using: Facebook (Facebook, AdMob, etc.)
- Platform you are using the Unity editor on: Mac, Windows (Mac, Windows, or Linux)
- Platform you are targeting: iOS, Android (iOS, Android, and/or desktop)
- Scripting Runtime: IL2CPP (Mono, and/or IL2CPP)
[REQUIRED] Please describe the issue here:
Hey Firebase team! The problem: If the user tries to register or login using his phone number the app crashes on iOS. Our use case: Currently we use custom Firebase apps. The app is configured from the code like this:
internal static Firebase.FirebaseApp CreateFirebaseAppBaseOnConfiguration()
{
Firebase.AppOptions appOptions = new Firebase.AppOptions() {
AppId = APP_ID,
ApiKey = API_KEY,
StorageBucket = STORAGE_BUCKET,
ProjectId = PROJECT_ID
};
Firebase.FirebaseApp app = Firebase.FirebaseApp.Create(appOptions, "SoulsideFirebaseApp");
return app;
}
The created Firebase app reference is provided to the Firebase services like this: _auth = Firebase.Auth.FirebaseAuth.GetAuth(app);
When the VerifyPhoneNumber method is called we get an crash:
PhoneAuthProvider provider = PhoneAuthProvider.GetInstance(_auth);
provider.VerifyPhoneNumber(...); // <--- The crash happens here!
The crash is unhandled exception that is thrown in Pods/FirebaseAuth/FIRPhoneAuthProvider.m ObjectiveC class on line 125:
- (void)verifyPhoneNumber:(NSString *)phoneNumber
UIDelegate:(nullable id<FIRAuthUIDelegate>)UIDelegate
completion:(nullable FIRVerificationResultCallback)completion {
if (![FIRAuthWebUtils isCallbackSchemeRegisteredForCustomURLScheme:_callbackScheme]) {
[NSException raise:NSInternalInconsistencyException
format:@"Please register custom URL scheme '%@' in the app's Info.plist file.",
_callbackScheme];
}
The _callbackScheme
is nil. It is initialized from _auth.app.options.clientID
in the same file:
- (nullable instancetype)initWithAuth:(FIRAuth *)auth {
self = [super init];
if (self) {
_auth = auth;
_callbackScheme = [[[_auth.app.options.clientID componentsSeparatedByString:@"."]
reverseObjectEnumerator].allObjects componentsJoinedByString:@"."];
}
return self;
}
When a custom Firebase app (configured from C# code, see above) is used the _auth.app.options
dictionary contains 6 key/values. If we use the Firebase.FirebaseApp.DefaultInstance
for the Auth the _auth.app.options
dictionary contains 8 key/values. The two additional key/values are: CLIENT_ID and DATABASE_URL.
If we go to the C# Firebase.AppOptions class we will see that we can not provide the ClientId. But it is required in iOS verifyPhoneNumber method.
Steps to reproduce:
Have you been able to reproduce this issue with just the Firebase Unity quickstarts (this GitHub project)? No What's the issue repro rate? (eg 100%, 1/5 etc)
What happened? How can we make the problem occur? Try the provide custom ClientId to the Firebase.AppOptions. This could be a description, log/console output, etc.
If you have a downloadable sample project that reproduces the bug you're reporting, you will likely receive a faster response on your issue.
Relevant Code:
Firebase.AppOptions appOptions = new Firebase.AppOptions() {
AppId = APP_ID,
ApiKey = API_KEY,
StorageBucket = STORAGE_BUCKET,
ProjectId = PROJECT_ID
// Can not provide ClientId here
};
Firebase.FirebaseApp app = Firebase.FirebaseApp.Create(appOptions, "SoulsideFirebaseApp");
return app;
Thanks for this ticket and I'm sorry for the inconvenience. We'll work to add a feature that includes an API surface for client ids in the Firebase Option configuration flow.