Firebase不支持的浏览器

时间:2017-10-16 07:36:20

标签: javascript firebase react-native firebase-realtime-database firebase-authentication

我在我的react-native应用程序中使用firebase。我不知道当我尝试使用firebase身份验证登录此错误时会发生什么。但是,昨天在我的申请中没有发生。我不知道为什么会这样。请帮帮我,我现在卡住了。

错误图片位于以下链接

https://i.stack.imgur.com/SieCM.jpg

这是我的源代码

import React, { Component } from 'react';
import {
  Text,
  View,
  TouchableOpacity,
  TextInput,
  Image,
  Button,
  AsyncStorage
} from 'react-native';
import FBSDK, { LoginButton, AccessToken } from 'react-native-fbsdk';
import { GoogleSignin, GoogleSigninButton } from 'react-native-google-signin';
import styles from '../components/style.js';
import firebase from '../components/Firebase.js';



export default class Signin extends Component {
    constructor(){
        super();
            this.state={
                email:'',
                password: ''
        }
    }

    componentWillMount() {
    GoogleSignin.hasPlayServices({ autoResolve: true }).then(() => {
    GoogleSignin.configure ({
      webClientId: '678031332619-ol6s25inanfpk0fkudjt5dhdhfd1m9ov.apps.googleusercontent.com'
        })
    })
    .catch((err) => {
    console.log("Play services error", err.code, err.message);
        })
    }

    signIn(){
        firebase.auth().signInWithEmailAndPassword(this.state.email, this.state.password).then((userData) => {
            AsyncStorage.setItem('userData', JSON.stringify(userData))
            alert("Sign in Success")
            this.props.navigation.navigate('Form');
        }).catch((e) => {
            alert(e)
        })
    }

    handleSigninGoogle() {
    GoogleSignin.signIn().then((user) => {
      console.log(user);
        }).catch((error) => {
      console.log('WRONG SIGNIN', error);
        }).done();
    }

    Signout() {
    GoogleSignin.signOut()
    .then(() => {
      console.log('out');
    })
    .catch((err) => {

    });
  }
    render() {
        console.ignoredYellowBox = ['Remote debugger'];
        const { navigate } = this.props.navigation;
    return (
    <View style={styles.container}>
        <Text style={styles.title}> 41 Studio IT Solutions </Text>

            <TextInput 
             style={styles.loginInput}
             onChangeText={(email) => this.setState({email})}
             value={this.state.email}
             underlineColorAndroid='transparent'
             placeholder='Email'
            />

            <TextInput 
             style={styles.loginInput}
             onChangeText={(password) => this.setState({password})}
             value={this.state.password}
             underlineColorAndroid='transparent'
             placeholder='Password'
             secureTextEntry
            />
            <View style={styles.main}>
            <TouchableOpacity
                style={styles.button}
                onPress={this.signIn.bind(this)}
            >
            <Text style={styles.buttonText}> Sign In </Text>
            </TouchableOpacity>

            <TouchableOpacity
                style={styles.button}
                onPress={() => navigate('Register')}
            >
            <Text style={styles.buttonText}> Register </Text>
            </TouchableOpacity>

            </View>
            <LoginButton
             style={styles.facebookButton}
             publishPremissions={["publish_actions"]}
             onLoginFinished= {(error, result) => {
                if(error) {
                    alert(error);
                }
                else if (result.isCancelled){
                    console.log('Cancelled')
                }
                else {
                    AccessToken.getCurrentAccessToken().then((data) => {
                        console.log(data.accessToken.toString())
                        const credential = firebase.auth.FacebookAuthProvider.credential(data.accessToken.toString());
                        firebase.auth().signInWithCredential(credential).catch((e) => console.log(e))
                        })
                    }
                }
            }
            onLogoutFinished={() => console.log("logout")}
            />
            <GoogleSigninButton
             style={styles.googleButton}
             size={GoogleSigninButton.Size.Wide}
             color={GoogleSigninButton.Color.Light}
             onPress={this.handleSigninGoogle.bind(this)}/>
            <Button onPress={() => this.Signout.bind(this)} title="Signout" />
      </View>
    );
  }
}

1 个答案:

答案 0 :(得分:0)

更新:firebase@4.5.2已解决此问题

这是相关问题,假设您使用的是firebase@4.5.1

https://github.com/firebase/firebase-js-sdk/issues/223

在发布较新版本之前,快速修复是降级到4.5.0