使用与Web和移动应用程序相同的Firebase应用程序 [英] Using Same Firebase App With Web and Mobile App

查看:146
本文介绍了使用与Web和移动应用程序相同的Firebase应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以说,我正在使用React构建一个Web应用程序,同时也是一个允许用户使用React Native拍摄照片的移动应用程序。我希望允许用户在登录到Web应用程序和移动应用程序时使用相同的登录凭据。我可以为网页应用和移动应用使用相同的Firebase信息吗?就像在下面的代码片段中包含代码片段,以允许他们使用相同的数据库,存储等?

 < script src =https://www.gstatic.com/firebasejs/3.6.1/firebase.js >< /脚本> 
< script>
//初始化Firebase
// TODO:替换为您的项目的自定义代码片段
var config = {
apiKey:< API_KEY>,
authDomain: < PROJECT_ID> .firebaseapp.com,
databaseURL:https://< DATABASE_NAME> .firebaseio.com,
storageBucket:< BUCKET> .appspot.com,
messagingSenderId:< SENDER_ID>,
};
firebase.initializeApp(config);
< / script>


解决方案

结束许多(iOS,Web和Android)应用程序。所有这些应用程序将与相同的后端服务通话。



因此,如果您在一个Firebase项目上创建两个Web应用程序,那么这些应用程序将使用相同的数据库,相同的用户列表,相同的存储文件等等。如果您然后添加iOS或Android应用程序,那也将访问相同的用户/数据库/文件。


So say I am building a web app using React and also a mobile app that allows users to take a photo using React Native. I want to allow users to use the same login credentials when signing into the web app and also the mobile app. Can I use the same Firebase info for both the web app and mobile app? Like just include the snippet below in both code bases to allow them to both use the same database, storage, etc?

<script src="https://www.gstatic.com/firebasejs/3.6.1/firebase.js"></script>
<script>
  // Initialize Firebase
  // TODO: Replace with your project's customized code snippet
  var config = {
    apiKey: "<API_KEY>",
    authDomain: "<PROJECT_ID>.firebaseapp.com",
    databaseURL: "https://<DATABASE_NAME>.firebaseio.com",
    storageBucket: "<BUCKET>.appspot.com",
    messagingSenderId: "<SENDER_ID>",
  };
  firebase.initializeApp(config);
</script>

解决方案

A single Firebase project can be used as the back-end for many (iOS, Web and Android) apps. All these apps will be talking to the same back-end services.

So if you create two web applications on a single Firebase project, those apps will be using the same database, the same list of users, the same stored files, etc. If you then add an iOS or Android app, that will also be accessing the same users/database/files.

这篇关于使用与Web和移动应用程序相同的Firebase应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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