小编Dav*_*ens的帖子

为什么我在.then()保证中失去了对this.state变量的访问权限?

我正在尝试使用firebase身份验证/数据库为react-native移动应用程序创建登录和注册过程.

我可以使用Login.js中的预先存在的电子邮件/密码成功登录.

当我尝试在SignUp.js中创建一个新帐户时,我的问题出现了

用户已正确添加到firebase身份验证,但我希望我的用户配置文件有更多信息.这就是为什么我用他们的名字,电子邮件和我从Signup.js第33行的代码中删除的其他信息写入数据库的原因,第52行有辅助函数.

我的错误undefined is not an object(evaluating this.state.email)来自SignUp.js中的第33行

这对我来说没有意义,因为我可以在SignUp.js的第27行成功创建用户 this.state.email

this.state.email走出去的范围有多大?任何帮助是极大的赞赏.

App.js

import React from 'react';
import { StackNavigator } from 'react-navigation';
import * as firebase from 'firebase'; 
import Dashboard from './components/Dashboard';
import Login from './components/Login';
import SignUp from './components/SignUp';

const Application = StackNavigator({
    Login: { screen: Login},
    SignUp: { screen: SignUp},
    Dashboard: { screen: Dashboard },
});

export default class App extends React.Component {
    componentWillMount(){
        const firebaseConfig = {
            apiKey: 'MY KEY',
            authDomain: …
Run Code Online (Sandbox Code Playgroud)

javascript firebase react-native firebase-authentication

4
推荐指数
1
解决办法
1543
查看次数

将 Expo/Google 登录链接到 Firebase 身份验证

我正在尝试使用 Expo 的 Google 登录功能并将该授权链接到我的 Firebase 身份验证。我无法理解如何将数据从从 Expo/google 服务接收/使用的身份验证令牌传输到我的 firebase 身份验证(即创建一个 firebase 标识符,UID)。我一直在关注有关链接身份验证和Google 登录的 Expo 文档的文档,这是我获得以下代码的地方。我也在stackoverflow 上查看了这个问题,但没有接受的答案。

对我来说,两个主要的困惑点是:

  1. Expo 的 google login 和 firebase 的 auth 使用类似但不同的方式来验证用户身份。世博会采用Expo.Google.logInAsync(),并且token同时使用火力firebase.auth.GoogleAuthProvider()auth.currentUser.linkWithRedirect(provider)credential

  2. 如果用户使用下面包含的 Expo/Google 方法登录,则 firebase在其数据库中没有该用户的记录,没有 UID,没有标识符。

如何确保如果用户使用以下方法登录,则会在 firebase auth 中创建用户?就像当一个人使用firebase.auth().createUserWithEmailAndPassword()

async logInWithGoogleAsync() {
    try {
        const result = await Expo.Google.logInAsync({
            iosClientId: 'XXX',
            scopes: ['profile', 'email'],
        });

        if(result.type === 'success') {

            //LINK ACCOUNTS HERE?  
            //Use result.accessToken …
Run Code Online (Sandbox Code Playgroud)

javascript firebase react-native firebase-authentication expo

2
推荐指数
1
解决办法
1470
查看次数

*虚拟*方法缺少“等待”返回值?

我有一个异步虚拟方法,该方法返回一个默认布尔值,该默认布尔值在我的应用程序的某些基本功能中使用。即,如果没有设置可做,则假定设置成功。

我了解非虚拟方法中的警告方法,但是我想知道在虚拟方法中实现此警告的最佳方法。我应该在虚方法中返回什么以确保删除此警告?还是我应该忽略?

// WARNING: This async method lacks 'await'
// virtual is the differentiating factor here
protected virtual async Task<bool> SetupAsync()
{
    return true;
}
Run Code Online (Sandbox Code Playgroud)

c# virtual asynchronous

2
推荐指数
1
解决办法
66
查看次数