Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The current environment does not support the specified persistence type

https://firebase.google.com/docs/auth/web/auth-state-persistence

The default for web browser and React Native apps is local (provided the browser supports this storage mechanism, eg. 3rd party cookies/data are enabled) whereas it is none for Node.js backend apps.

When I try the following in my React Native Android app:

const signIn = () =>
  firebase.auth().setPersistence(firebase.auth.Auth.Persistence.LOCAL).then(() => {
    return firebase.auth().signInAnonymously();
  });

I get the following error:

The current environment does not support the specified persistence type.

Is this a bug or have I missed something from the docs?

Environment:

"dependencies": {
    "firebase": "^4.5.0",
    "react": "16.0.0-alpha.12",
    "react-native": "^0.48.4",
  }

Android 7.0
like image 657
Prashanth Chandra Avatar asked Nov 17 '25 06:11

Prashanth Chandra


1 Answers

Seems there's a bug in selectively importing firebase modules.
Changing the imports from

import * as firebase from 'firebase/app';
import 'firebase/auth';

to

import firebase from 'firebase';  

solved the issue.

like image 87
Prashanth Chandra Avatar answered Nov 18 '25 20:11

Prashanth Chandra



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!