问题
I've been trying to get the Facebook login snippet from Firebase's documentation to work but I get the following console error:
window.open is not a function
What is the correct way to implement Firebase's Facebook login on a React Native app ?
回答1:
This was answered in How to use Firebase Twitter Authentication with React Native?
It's because the JavaScript version of Firebase was written for the web and not React Native. Most of the API works correctly except for:
- Social authentication. Uses browser functions to open a new window or redirect.
- Caching data and authentication. Looks like it's built for synchronous local storage instead of React Native's asynchronous storage.
I started using Firebase Web for my React Native app and implemented Facebook login using the Facebook iOS SDK as a native module then passing the token to authWithOAuthToken
.
Now that I've found persistence doesn't work either I'm considering using the Firebase iOS and Android APIs wrapping only the required methods as native modules instead of trying to re-implement persistence.
来源:https://stackoverflow.com/questions/32940326/firebases-facebook-login-on-react-native-android