Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/233.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Firebase函数混淆:哪个数据库?_Android_Firebase_Google Cloud Firestore_Google Cloud Functions - Fatal编程技术网

Android Firebase函数混淆:哪个数据库?

Android Firebase函数混淆:哪个数据库?,android,firebase,google-cloud-firestore,google-cloud-functions,Android,Firebase,Google Cloud Firestore,Google Cloud Functions,老实说,我根本不知道如何指定我正在与哪个数据库交谈。FireStore是否被视为一个巨大的数据库,所有应用程序的文档和集合都是并排存在的 我是否必须为集合指定特定于应用程序的名称。。。比如某个应用程序用户,其他应用程序用户,以及其他应用程序用户?还是怎样只是在/users下相互混合用户 我正在阅读Firebase文档,我看到的都是引用特定集合或文档的代码行,但没有一行引用任何名称空间或数据库 没有设置,也没有配置它应该指向的位置,您只需使用firebase登录,然后运行 firebase仅部署功

老实说,我根本不知道如何指定我正在与哪个数据库交谈。FireStore是否被视为一个巨大的数据库,所有应用程序的文档和集合都是并排存在的

我是否必须为集合指定特定于应用程序的名称。。。比如某个应用程序用户,其他应用程序用户,以及其他应用程序用户?还是怎样只是在/users下相互混合用户

我正在阅读Firebase文档,我看到的都是引用特定集合或文档的代码行,但没有一行引用任何名称空间或数据库

没有设置,也没有配置它应该指向的位置,您只需使用firebase登录,然后运行

firebase仅部署功能

然后是魔法

有没有人能解释一下,在没有设置的情况下,应用程序如何与特定功能进行通信

最糟糕的是,当我在应用程序中看到这篇写作指南时。就像这里,两个不同的存储库,一个后端和一个应用程序。。。应用程序如何知道您将编写哪些quintillion后端函数来订阅

 return admin.messaging().sendToDevice(registrationTokens, payload).then( response => {
            const stillRegisteredTokens = registrationTokens

            response.results.forEach((result, index) => {
.sendToDevice如何不发送到世界上所有的设备,而只发送到那些特定于应用程序的设备。。。在另一个存储库中再次设置。。。没有配置,没有指向那个的。在哪里发生的

该功能如何只知道向与此相关的特定Android应用程序发送消息

// The Cloud Functions for Firebase SDK to create Cloud Functions and setup triggers.
const functions = require('firebase-functions');

// The Firebase Admin SDK to access the Firebase Realtime Database.
const admin = require('firebase-admin');
admin.initializeApp();

// Take the text parameter passed to this HTTP endpoint and insert it into the
// Realtime Database under the path /messages/:pushId/original
exports.addMessage = functions.https.onRequest((req, res) => {
    // Grab the text parameter.
    const original = req.query.text;
    // Push the new message into the Realtime Database using the Firebase Admin SDK.
    return admin.database().ref('/messages').push({original: original}).then((snapshot) => {
        // Redirect with 303 SEE OTHER to the URL of the pushed object in the Firebase console.
        return res.redirect(303, snapshot.ref.toString());
    });
});

// Listens for new messages added to /messages/:pushId/original and creates an
// uppercase version of the message to /messages/:pushId/uppercase
exports.makeUppercase = functions.database.ref('/messages/{pushId}/original')
.onCreate((snapshot, context) => {
    // Grab the current value of what was written to the Realtime Database.
    const original = snapshot.val();
    console.log('Uppercasing', context.params.pushId, original);
    const uppercase = original.toUpperCase();
    // You must return a Promise when performing asynchronous tasks inside a Functions such as
    // writing to the Firebase Realtime Database.
    // Setting an "uppercase" sibling in the Realtime Database returns a Promise.
    return snapshot.ref.parent.child('uppercase').set(uppercase);
});

无论何时在firebase中创建项目,都需要下载名为google-services.json的文件。这个文件看起来像

还有更多。它指定您正在处理的项目。如果您使用firebase在后端工作,同样适用,您需要使用一个特殊的配置文件,这会告诉您的本地项目它将使用哪个firebase项目

每个firebase项目都有自己的数据库、cloud firestore或realtime,因此您一次只能更改一个数据库,即与该小文件/项目关联的数据库

firebase中包含的通知和其他所有内容也是如此。所有这些都限制在google-services.json文件指定的项目中

当你上传一个云功能时,你把它上传到一个特定的项目中,这将使它们与该项目的设备一起工作,通常该项目的设备具有与该项目相关联的google-services.json文件

.sendToDevice如何不发送到世界上所有的设备,而只发送到那些特定于应用程序的设备。。。在另一个存储库中再次设置。。。没有配置,没有指向那个的。在哪里发生的

每个Firebase客户端SDK都允许您在设备上创建注册令牌,例如智能手机上的应用程序。在设备上创建该令牌后,需要将其保存在Firestore的文档或实时数据库中

Android上的设备注册令牌:

现在,您可以使用此令牌在Firebase功能内通过Firebase云消息发送消息

在Firebase向单个设备发送文档:

啊,是的,在您通过运行firebase init函数创建的项目中,有一个.firebaserc文件,指定您将其附加到的项目。非常感谢。这让我感到困惑,因为firebase工具登录到了一个不同但与我为firebase控制台创建项目的用户相似的用户。现在事情变得更有意义了。
{
  "project_info": {
    "project_id": "mockproject-1234",
    "project_number": "123456789000",
    "name": "FirebaseQuickstarts",
    "firebase_url": "https://mockproject-1234.firebaseio.com"
  },