镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

createUserWithEmail does not work at all on andorid. #140

Description

@thesabbir

firestack.auth.createUserWithEmail does not work at all on android.
Working fine with iOS.

Activity

  1. thesabbir commented on Nov 17, 2016

    @thesabbir
    Author

    #63 might be on android too.

  2. auser commented on Nov 17, 2016

    @auser
    Contributor

    There is work on a new branch by @Salakar that will replace the current auth version work. Hopefully we'll have the new stuff merged in soon/this weekend.

  3. Salakar commented on Nov 17, 2016

    @Salakar
    Collaborator

    @thesabbir feel free to give my branch a go - just remember it's now in line with the firebase web api, so your code above becomes:

    firestack.auth().createUserWithEmailAndPassword(email, password).then().catch()

    And you can get the current user the same way as the web api:

    if (firestack.auth().currentUser) {
      console.warn(firestack.auth().currentUser.email);
      // firestack.auth().currentUser.updatePassword(newPassword).then().catch();
    }
  4. thesabbir commented on Nov 17, 2016

    @thesabbir
    Author

    No luck.

    Installation:

    rm -rf ./node_modules/react-native-firestack
    git clone https://github.com/Salakar/react-native-firestack.git node_modules/react-native-firestack --depth=1
    

    My Code:

    import Firestack from 'react-native-firestack';
    
    const firestack = new Firestack({ debug: true });
    
    firestack.auth().onAuthStateChanged(user => {
        if (user) {
            console.log(user)
        } else {
            console.log('Not signed in');
        }
    });
    
    firestack.auth().signInWithEmailAndPassword('email@example.com', 'A123456')
        .catch(e => {
            console.log(e)
        });
    
    console.log(firestack.auth().currentUser);

    Verbose console output:

    debugger-ui:83 Console was cleared
    log.js:20firestack             | [info] Creating new firestack instance
    log.js:20firestack             | [info] Calling configure with options Objectdebug: true__proto__: Object
    log.js:20firestack:auth        | [info] Creating onAuthStateChanged listener
    log.js:20firestack:auth        | [info] Signing in user with email and password email@example.com
    firebase.js:17null
    AppRegistry.js:97Running application "penalty" with appParams: {"initialProps":{},"rootTag":1}. __DEV__ === true, development-level warning are ON, performance optimizations are OFF
    firebase.js:7Objectauthenticated: falseeventName: "listenForAuth"__proto__: Object
    YellowBox.js:69Debugger and device times have drifted by more than 60s. Please correct this by running adb shell "date `date +%m%d%H%M%Y.%S`" on your debugger machine.console.warn @ YellowBox.js:69emitTimeDriftWarning @ JSTimersExecution.js:230__callFunction @ MessageQueue.js:236(anonymous function) @ MessageQueue.js:108guard @ MessageQueue.js:46callFunctionReturnFlushedQueue @ MessageQueue.js:107onmessage @ debuggerWorker.js:44
    log.js:20 firestack             | [info] Native error occurred while calling configure Object {msg: "FirebaseApp name [DEFAULT] already exists!"}msg: "FirebaseApp name [DEFAULT] already exists!"__proto__: Object
    firebase.js:7 Object {errorMessage: "No current user", errorCode: 100}
    
    

    works fine on iOS though :(

  5. Salakar commented on Nov 17, 2016

    @Salakar
    Collaborator

    @thesabbir can you try the below, added comments - appears to be working here, not sure what part isn't working?

    import Firestack from 'react-native-firestack';
    
    const firestack = Firestack.initializeApp({
      debug: '*',
    });
    
    firestack.auth().onAuthStateChanged(() => {
        if (firestack.auth().currentUser) {
            console.log(firestack.auth().currentUser.isAnonymous);
        } else {
            console.log('Not signed in');
        }
    });
    
    firestack.auth()
        .signInWithEmailAndPassword('email@example.com', 'A123456')
        .then((u) => {
             console.warn(firestack.auth().currentUser.email);
             console.warn(firestack.auth().currentUser.uid);
        })
        .catch(e => {
            console.log(e)
        });
    
    // this won't work - it's synchronous - so will be called before signInWithEmailAndPassword is finished
    // console.log(firestack.auth().currentUser);
    // you'd use this to check if already signed in, for example:
    // if (!firestack.auth().currentUser) { // do sign-in/register logic } else { // already signed in }
  6. thesabbir commented on Nov 17, 2016

    @thesabbir
    Author

    console.log(firestack.auth().currentUser); was only there to see initial value.

    I tried running your code.
    Good news is it works fine on my 6.0.1 device.
    But doesn't work on 6.0.0 genymotion, which is odd 😕

  7. Salakar commented on Nov 17, 2016

    @Salakar
    Collaborator

    I assume genymotion doesn't have play services? Firebase needs google play services integration to work

  8. tegument commented on Nov 17, 2016

    @tegument

    yes you need to install google play services on genymotion virtual device:
    https://github.com/codepath/android_guides/wiki/Genymotion-2.0-Emulators-with-Google-Play-support

  9. Salakar commented on Nov 19, 2016

    @Salakar
    Collaborator

    Closing as fixed on v3 branch. Side note, I'm adding in a play services check into the android code, should at least warn now if no play services.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions