Firebase的Facebook登录React-native-android [英] Firebase's Facebook login on React-native-android

查看:374
本文介绍了Firebase的Facebook登录React-native-android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试从Firebase的文档中获取Facebook登录代码片段,但是出现以下控制台错误:


窗口.open不是一个函数


在React Native应用程序上实现Firebase的Facebook登录的正确方法是什么? b $ b

解决方案

这个答案在如何使用Firebase Twitter身份验证与React Native?

这是因为Firebase的JavaScript版本是为网络而不是反应本机。除了:


  • 社交身份验证以外,大多数API都能正常工作。使用浏览器功能打开新窗口或
    重定向。
  • 缓存数据和身份验证。看起来像是为同步本地存储而不是React Native的异步
    存储构建了


    $ b 我开始使用Firebase Web用于我的React Native应用程序,并使用Facebook iOS SDK作为本机模块实施Facebook登录,然后将令牌传递给 authWithOAuthToken



    现在,我发现持久性不起作用,要么我正在考虑使用Firebase iOS和Android API,只将必需的方法作为本机模块,而不是试图重新实现持久性。


    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 ?

    解决方案

    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.

    这篇关于Firebase的Facebook登录React-native-android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆