Mayis Gh
Mayis Gh

Reputation: 11

Firebase Auth failed on iOS (Unity, Xcode)

I am trying to make Firebase Unity SDK work on iOS 13 device. I was able to build the project, but the issue is I am not able sign up or authenticate user.

Steps to Reproduce: (What I did)

  1. Downloaded quickstart-unity/auth/testapp project
  2. Opened in Unity 2019.2.20f1 with iOS platform
  3. Changed Bundle ID to the one I have registered in Firebase Console
  4. Put GoogleService-Info.plist under Assets/Firebase folder
  5. Set Resolver iOS settings option Add CocoaPods to the Xcode project
  6. Imported the latest Firebase Auth package 6.10.0 from dotnet4 folder to the project
  7. Did build

What I see in Xcode project:

  1. PodFile content looks like this:
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'

target 'Unity-iPhone' do
  pod 'Firebase/Auth', '6.14.0'
  pod 'Firebase/Core', '6.14.0'
end
  1. GoogleService-Info.plist is in Xcode project hierarchy too

Signed and build on my iPhone 8 with iOS 13.

Result: When I try to fill fields email and password and push button "Create User" which calls the method:

// Create a user with the email and password.
    public Task CreateUserWithEmailAsync() {
      DebugLog(String.Format("Attempting to create user {0}...", email));
      DisableUI();

      // This passes the current displayName through to HandleCreateUserAsync
      // so that it can be passed to UpdateUserProfile().  displayName will be
      // reset by AuthStateChanged() when the new user is created and signed in.
      string newDisplayName = displayName;
      return auth.CreateUserWithEmailAndPasswordAsync(email, password)
        .ContinueWithOnMainThread((task) => {
          EnableUI();
          if (LogTaskCompletion(task, "User Creation")) {
            var user = task.Result;
            DisplayDetailedUserInfo(user, 1);
            return UpdateUserProfileAsync(newDisplayName: newDisplayName);
          }
          return task;
        }).Unwrap();
    }

I see this error on device screen and in Xcode logs too:

AuthError.Failure: Firebase.FirebaseException: An internal error has occurred, print and inspect the error details for more information.

Here is full log from Xcode:

https://drive.google.com/file/d/1ZQzrA67NXqM-lwNsSqT8Dgam9XiSHD9y/view?usp=sharing

Also I tried to do:

  1. Build on device with lower iOS version.
  2. Tried to build with Unity 2019.1.11 and 2019.1.13 versions
  3. Tried to import GoogleService-Info.plist directly to Xcode project
  4. Tried Firebase SDK 6.8.0 version
  5. Tried to add [FIRApp configure] manually
  6. Nothing worked.

Firebase console configured for project and contains two apps android and iOS with different Bundle IDs. Android version works perfect tested many time.

Unity editor version: 2019.2.20f1

Firebase Unity SDK version: 6.10.0

Firebase plugins in use: Auth

Additional SDKs we are using (Facebook, AdMob, etc.): None

Platform we are using the Unity editor on: Mac

Platform we are targeting: iOS

Scripting Runtime: IL2CPP

Xcode version: 11 (the latest)
CocoaPods: The latest version

Upvotes: 0

Views: 1654

Answers (3)

Onat Korucu
Onat Korucu

Reputation: 1042

I was seeing "CreateUserWithEmailAndPasswordAsync encountered an error: System.AggregateException: An internal error has occurred." in the Unity console.

To fix, I closed Unity, committed my important changes, and re-opened Unity. In the pop-up that appeared, I clicked "Enable". EnableAndroidResolutionPopup

Meanwhile, I also went to my project settings in the Firebase console (https://console.firebase.google.com/project/myprojectname/authentication/providers) and enabled mail signup. It is also advised in the video tutorial, but not in the written one. Firebase Official Video Tutorial

After that, problem got solved.

Upvotes: 0

Mayis Gh
Mayis Gh

Reputation: 11

At least I was able to fix the problem. Here is the description how I fixed it.

As I mentioned above Unity was exporting PodFile like this:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'

target 'Unity-iPhone' do
  pod 'Firebase/Auth', '6.14.0'
  pod 'Firebase/Core', '6.14.0'
end

So this means Firebase Unity SDK 6.10.0 requires Pods version 6.14.0. Building with this pods I was seeing error mentioned above:

[SA LOG] CreateUserWithEmailAndPasswordAsync encountered an error: System.AggregateException: One or more errors occurred. ---> System.AggregateException: One or more errors occurred. ---> Firebase.FirebaseException: An internal error has occurred, print and inspect the error details for more information.
   --- End of inner exception stack trace ---
   --- End of inner exception stack trace ---
---> (Inner Exception #0) System.AggregateException: One or more errors occurred. ---> Firebase.FirebaseException: An internal error has occurred, print and inspect the error details for more information.
   --- End of inner exception stack trace ---
---> (Inner Exception #0) Firebase.FirebaseException: An internal error has occurred, print and inspect the error details for more information.<---
<---

As you can see this error says nothing.

After doing long research I noticed in CocoaPods website there are newer versions for Firebase pods available so I changed my PodsFile like this manually and installed Pods using terminal:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'

target 'Unity-iPhone' do
  pod 'FirebaseAnalytics', '~> 6.2'
  pod 'FirebaseAuth', '~> 6.4'
  pod 'FirebaseCore', '~> 6.6'
end

After building I was able to get human readable error which says:

Response body: {
  "error": {
    "code": 400,
    "message": "API key expired. Please renew the API key.",
    "status": "INVALID_ARGUMENT",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.Help",
        "links": [
          {
            "description": "Google developer console API key",
            "url": "https://console.developers.google.com/project/37062923653/apiui/credential"
          }
        ]
      }
    ]
  }
}

I updated API key in Google Developer Console as error says and now everything works well.

Conclusion:

This wasn't issue related to Firebase Unity SDK 6.10.0 and nor 6.8.0, and also this wasn't related to Parse DLLs. Just the problem was the older versions 6.14.0 for Firebase Pods not giving human readable error, so I wasn't able to understand what was going on. After using latest Firebase Pods I was able to understand error reason.

Thanks everyone who responded to my problem.

Upvotes: 1

Dharmik
Dharmik

Reputation: 257

you need to check your Xcode Info.Plist file there need to add key for google login. Link

also see your logs line 3 need to remove one key.

Upvotes: 0

Related Questions