Papp Zoltán
Papp Zoltán

Reputation: 181

React Native how to restore a firebase session with tokenid

How can I restore a sessionid in Firebase auth?

public async saveSessionId() {
    return auth().currentUser?.getIdToken().then((id) => {
        this.sessionId = id;
        AsyncStorage.setItem('@tokenid', this.sessionId);
    });
}

public async signInWithSessionId() {
    const credential = firebase.auth.???.credential(this.sessionId);
    return auth().signInWithCredential(credential);
}

Is there any provider or any method for reload session after reload the program?

Upvotes: 0

Views: 130

Answers (1)

tushali_jasoliya
tushali_jasoliya

Reputation: 251

Maybe this one method will help you to reload the session.

public async signInWithSessionId() {
    const credential = firebase.auth().signInWithCustomToken(this.sessionId);
    return credential.user;
}

Upvotes: 1

Related Questions