currentUser is null after restart

671 views
Skip to first unread message

Alex Rudyk

unread,
Aug 26, 2016, 4:32:17 PM8/26/16
to Firebase Google Group
I am using Firebase Web SDK 3.3.0 with React Native app and working on Facebook login feature. I added react native Facebook SDK (JS wrapper on top of native FB SDK) and got Facebook auth token from it. Then I login with firebase with this code snippet:


    facebookLogin(token: string): Rx.Observable<UserModel> {
        const credential = Fb.auth.FacebookAuthProvider.credential(token);
        const signInPromise = Fb.auth().signInWithCredential(credential) as Promise<Fb.User>;
 
        return Rx.Observable
            .fromPromise(signInPromise)
            .map((user, idx) => new UserModel(user));
    }

Everything works fine and I am able to get Firebase User back and check that currentUser is not null.

The problems is that after app restart currentUser is null and Firebase.auth().onAuthStateChanged() never gets a user.

Is that a bug, or I am doing something wrong?

alex

Jacob Wenger

unread,
Aug 26, 2016, 6:07:10 PM8/26/16
to fireba...@googlegroups.com
Hey Alex,

Is the listener triggering with null? Or is not triggering at all? We've tested the 3.3.0 SDK on our React Native test app via the simulator and the user state was maintained.

We unfortunately don't have enough information to reproduce this issue. Is there any way you could give us some more info?

Cheers,
Jacob

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/3d61e6dd-9e2d-4270-85bd-78e3b2d712dd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alex Rudyk

unread,
Aug 28, 2016, 6:59:17 PM8/28/16
to Firebase Google Group
The problem was in firebase.initializeApp() call. My app has a business logic implemented as a separate JS module and that module was calling firebase.initializeApp(). After I moved that call into main React Native app (in index.ios.js) currentUser got preserved between restarts.

Any ideas why this matter?

alex


On Friday, August 26, 2016 at 3:07:10 PM UTC-7, Jacob Wenger wrote:
Hey Alex,

Is the listener triggering with null? Or is not triggering at all? We've tested the 3.3.0 SDK on our React Native test app via the simulator and the user state was maintained.

We unfortunately don't have enough information to reproduce this issue. Is there any way you could give us some more info?

Cheers,
Jacob
On Fri, Aug 26, 2016 at 1:29 PM, Alex Rudyk <alex....@gmail.com> wrote:
I am using Firebase Web SDK 3.3.0 with React Native app and working on Facebook login feature. I added react native Facebook SDK (JS wrapper on top of native FB SDK) and got Facebook auth token from it. Then I login with firebase with this code snippet:


    facebookLogin(token: string): Rx.Observable<UserModel> {
        const credential = Fb.auth.FacebookAuthProvider.credential(token);
        const signInPromise = Fb.auth().signInWithCredential(credential) as Promise<Fb.User>;
 
        return Rx.Observable
            .fromPromise(signInPromise)
            .map((user, idx) => new UserModel(user));
    }

Everything works fine and I am able to get Firebase User back and check that currentUser is not null.

The problems is that after app restart currentUser is null and Firebase.auth().onAuthStateChanged() never gets a user.

Is that a bug, or I am doing something wrong?

alex

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages