Firebase不会在Unity SDK中创建用户 [英] Firebase do not create user in Unity SDK
问题描述
奇怪的是,Firebase无法在Unity SDK中创建用户。
调整了Firebase控制台(启用了匿名访问和电子邮件/密码访问),并将google-service.json放置在Unity的Assets文件夹中。
Firebase仍然不会创建用户。这是它总是失败的代码:
$ p $ auth.SignInAnonymouslyAsync()。ContinueWith(task => {
if(task.IsCompleted&!task.IsCanceled&&!task.IsFaulted){
Debug.Log(User is now signed in。);
FirebaseUser newUser = task。结果;
}
else if(task.IsFaulted || task.IsCanceled)
{
Debug.Log(用户注册失败);
}
});
为什么?
可能有以下几个原因:
- 该应用程序在编辑器中运行,而不是在设备上运行
- 添加Firebase身份验证功能后配置文件不会更新
- 密码短于6个字符
- 电子邮件地址无效,例如abcdef @ aaa
第一个原因很可能是原因。
我创建了
It is strange that Firebase can't create user in Unity SDK out of the box. Firebase Console was tuned (anonymous access and email/password access are enabled) and google-service.json was placed in Assets folder of Unity.
However, Firebase still won't create a user. This is the code where it always fails:
auth.SignInAnonymouslyAsync().ContinueWith(task => {
if (task.IsCompleted && !task.IsCanceled && !task.IsFaulted) {
Debug.Log("User is now signed in.");
FirebaseUser newUser = task.Result;
}
else if (task.IsFaulted || task.IsCanceled)
{
Debug.Log("User signup failed");
}
});
Why?
There are possible several reasons:
- The app was run in the Editor, rather than on the device
- The configuration file is not updated after you add Firebase Auth feature
- The password is shorter than 6 chacters
- The email address is in invalid form, e.g. abcdef@aaa
The first one is highly likely the reason why.
I have created a tutorial here, which covers the steps to create/login using firebase in Unity, hope this is helpful.
这篇关于Firebase不会在Unity SDK中创建用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!