Repository navigation
createUserWithEmail does not work at all on andorid. #140
Description
Activity
#63 might be on android too.
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.
@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(); }
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=1My 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 :(
@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 }
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 😕I assume genymotion doesn't have play services? Firebase needs google play services integration to work
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-supportClosing 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.
firestack.auth.createUserWithEmaildoes not work at all on android.Working fine with iOS.