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.
當我嘗試在我的陣營原生Android應用程序如下:
const signIn =() =>
firebase.auth().setPersistence(firebase.auth.Auth.Persistence.LOCAL).then(() => {
return firebase.auth().signInAnonymously();
});
我收到以下錯誤:
The current environment does not support the specified persistence type.
這是一個錯誤還是我錯過了文檔中的某些東西?
環境:
"dependencies": {
"firebase": "^4.5.0",
"react": "16.0.0-alpha.12",
"react-native": "^0.48.4",
}
Android 7.0
嘿Prashanth,這是在4.2.0發佈:https://firebase.google.com/support/release-notes/js#4.2.0你可以嘗試降級到該版本,看看這是一個迴歸? – bojeil
降級到4.2.0並未解決問題。添加'firebase.default.INTERNAL.extendNamespace({ INTERNAL:{ reactNative:{ AsyncStorage:AsyncStorage }} });'前右側設置持久性使錯誤消失,雖然AUTH仍不之間仍然存在應用程序重新啓動(每次不同的user.uid)。 –
我找到了根本原因。我使用的是選擇性導入,即'import * from'firebase/app' import'firebase/auth''。切換到從'firebase''導入Firebase解決了這個問題。 –