Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Bug] User ID change between firebase versions #896

Open
@murilobast

Description

[REQUIRED] Please fill in the following fields:

  • Unity editor version: 2021年3月19日f1
  • Firebase Unity SDK version: 10.3.0
  • Source you installed the SDK: .unitypackage
  • Problematic Firebase Component: Auth (Auth, Database, etc.)
  • Other Firebase Components in use: Firestore, Analytics, CloudFunctions, Crashlytics
  • Additional SDKs you are using: Facebook, AdMob
  • Platform you are using the Unity editor on: Mac
  • Platform you are targeting: iOS
  • Scripting Runtime: IL2CPP
  • Pre-built SDK from the website or open-source from this repo: prebuilt

[REQUIRED] Please describe the issue here:

I have updated Firebase to 11.4.0 months ago, everything worked fine until I tried running a standalone Windows build, had the good and old crash on start that is usually fixed by installing redistributables (check box on steamworks).
Knowing that 10.3.0 worked before I rolled back to 10.3.0 and things started working again.

All good until I tried to build for iOS, everything works correctly but for some reason the userId I get from firebase auth is different from what I get with 11.4.0 or what I used to get with 10.3.0. No code has changed on my side, it was just a version change. And to confirm it was the version, if I build with 11.x.0 I get the correct userId, but with 10.x.0 I get a new one.

Example code below:

On 11.x.0 newUser.UserId is cuzPiRT7QFgPZ2COBC0hbMGlvGU2
On 10.x.0 newUser.UserId is Y7Bj2PKv3maCmrPIMdTGd1YluUC3

Steps to reproduce:

Upgrade to 11.x.0
Fetch the userId
Downgrade to 10.x.0
Fetch the userId
userId is now different on 10.x.0

Relevant Code:

using UnityEngine;
using UnityEngine.SocialPlatforms.GameCenter;
public class GameCenterLogin {
	public static void Initialize() {
		GameCenterPlatform.ShowDefaultAchievementCompletionBanner(true);
		Social.localUser.Authenticate((bool success) => {
			if (success) SignInWithGameCenterAsync();
			else CloudLogin.OnFail();
		});
	}
	private static void SignInWithGameCenterAsync() {
		Firebase.Auth.FirebaseAuth auth = Firebase.Auth.FirebaseAuth.DefaultInstance;
		var credentialTask = Firebase.Auth.GameCenterAuthProvider.GetCredentialAsync();
		credentialTask.ContinueWith(cTask => {
			if (!cTask.IsCompleted || cTask.Exception != null || cTask.IsCanceled || cTask.IsFaulted) {
				Debug.Log("GCL credentialTask failed" + cTask.Exception.Message);
				CloudLogin.OnFail();
				return null;
			}
			var credential = cTask.Result;
			auth.SignInWithCredentialAsync(credential).ContinueWith(task => {
				if (task.IsCanceled || task.IsFaulted) {
					CloudLogin.OnFail();
					Debug.Log("GCL SignInWithCredentialAsync failed");
					return;
				}
				Firebase.Auth.FirebaseUser newUser = task.Result;
				CloudLogin.OnSuccess(newUser.DisplayName, newUser.UserId);
			});
			return credential;
		});
	}
	public static void OpenRankingUI() {
		Social.ShowLeaderboardUI();
	}
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /