将多个Firebase项目链接到单个Ionic 3应用程序

时间:2018-10-11 09:31:00

标签: angular firebase ionic3 firebase-authentication google-cloud-firestore

我正在使用Ionic 3开发一个简单的应用程序,该应用程序已经链接到他的Firebase项目,该项目必须管理另一个Firebase项目中的Firestore数据库。

问题是:有一种方法可以将多个Firebase项目与Ionic 3链接?

我正在使用angularfire2,并且已经阅读了官方的Firebase文档:https://firebase.google.com/docs/configure/#use_multiple_projects_in_your_application

但是我不明白如何使用Ionic 3

1 个答案:

答案 0 :(得分:0)

文档非常清楚该怎么做。示例:

const firstAppConfig = {
    apiKey: "<API_KEY>",
    authDomain: "<PROJECT_ID>.firebaseapp.com",
    databaseURL: "https://<DATABASE_NAME>.firebaseio.com",
    storageBucket: "<BUCKET>.appspot.com",
};

const firstFirebase = firebase.initializeApp(firstAppConfig, "first")

const secondAppConfig = {
    apiKey: "<API_KEY>",
    authDomain: "<PROJECT_ID>.firebaseapp.com",
    databaseURL: "https://<DATABASE_NAME>.firebaseio.com",
    storageBucket: "<BUCKET>.appspot.com",
};

const secondFirebase = firebase.initializeApp(secondAppConfig, "second")

const thirdAppConfig = {
    apiKey: "<API_KEY>",
    authDomain: "<PROJECT_ID>.firebaseapp.com",
    databaseURL: "https://<DATABASE_NAME>.firebaseio.com",
    storageBucket: "<BUCKET>.appspot.com",
};

const thirdFirebase = firebase.initializeApp(thirdAppConfig, "third")