小编zko*_*ohi的帖子

Firestore / Firebase模拟器未运行

我正在尝试使用此处列出的指南在本地测试我的功能 :https://firebase.google.com/docs/functions/local-emulator

我已经安装了最新的firebase-tools

npm install -g firebase-tools

在我package.json我确认正在运行

"firebase-admin": "^7.3.0",
"firebase-functions": "^2.3.1",
Run Code Online (Sandbox Code Playgroud)

当我尝试使用以下命令运行函数时

firebase emulators:start

它给了我下面的输出。我究竟做错了什么?

Starting emulators: ["functions"]
?  Your requested "node" version "8" doesn't match your global version "11"
?  functions: Emulator started at http://localhost:5001
i  functions: Watching "[FUNCTIONS FOLDER PATH]" for Cloud Functions...
?  Default "firebase-admin" instance created!
?  Ignoring trigger "[FUNCTION NAME]" because the service "firebaseauth.googleapis.com" is not yet supported.
?  Ignoring trigger "[FUNCTION NAME]" because the Cloud Firestore emulator is not running. …
Run Code Online (Sandbox Code Playgroud)

firebase firebase-tools google-cloud-functions google-cloud-firestore firebase-cli

8
推荐指数
6
解决办法
5677
查看次数

当 flutter 应用程序终止时,正常的推送通知会静默或根本不出现

我在 nodejs 上使用 firebase-admin 向用户发送推送通知:https ://firebase.google.com/docs/admin/setup

我在颤振上使用 firebase_messaging:https : //pub.dev/packages/firebase_messaging

我正在尝试在 android 和 ios 上发送具有最高优先级的推送通知。

firebase.messaging(firebaseApp).send({
    token,
    notification,
    android: { priority: 'high' },
    apns: { headers: { 'apns-priority': '10' }, payload: { aps: { sound: 'default' } } },
    data
}
Run Code Online (Sandbox Code Playgroud)

在我的开发设备上,它在应用程序处于后台和终止时都非常有用。

我在 android 和 ios 上都收到推送通知,这些通知在 100% 的时间里明显弹出并发出声音。

问题出在其他设备上 -

如果应用程序在后台,我有时会看到实际的推送通知明显弹出,并发出应有的声音。有时不是。

如果应用程序终止,则会收到推送通知 - 但它既不会明显弹出也不会发出声音,我只能在从屏幕顶部向下滚动菜单时才能看到它,它被列为收到的推送通知。有时根本没有收到通知。

我也尝试将应用程序中通知的优先级更改为实际设备上的高,但没有任何改变。

我的用户一直抱怨他们没有收到推送通知 - 我猜他们要么实际上没有收到它们,要么只是没有看到它们,因为它们是按照我上面描述的静默收到的。

我真的不知道发生了什么以及为什么它不能在我自己的开发设备以外的设备上正常工作。

有任何想法吗?

push-notification node.js firebase flutter firebase-cloud-messaging

7
推荐指数
1
解决办法
3567
查看次数

如何使用 Firestore 定义特定的 .env 文件到 Firebase Deploy

所以基本上我想将我的开发 Firestore 数据库与我的部署数据库分开。

我创建了 2 个 Firebase 项目:

  • myapp-dev
  • myapp-产品

我还创建了 2 个 .env 文件:

  • .env.development
  • .env.生产

Firebase 托管工作正常,因为我正在使用firebase use,然后我选择要托管代码的那个。问题出在 Firebase FireStore 上。由于它们都是 Firebase 项目,因此在部署时,它们将被视为生产项目。

那么有没有一种方法可以让我对 Firebase 说某个项目是用于开发或暂存目的呢?或者有没有办法部署到 Firebase 强制我的 .env.development 文件?

environment-variables firebase reactjs google-cloud-firestore dotenv

6
推荐指数
1
解决办法
5086
查看次数

带有通配符路径的 Firestore 云函数触发器

我们是一个无模式模型,我想在将文档添加到集合时触发云函数defects。问题是任何都defect可以包含一组新的缺陷集合(递归)。

如何设置在更新/创建以下任何文档时触发的云功能:

problem/defects/{document}

problem/defects/{document}/defects/{document}

problem/defects/{document}/defects/{document}/defects/{document}

problem/defects/{document}/defects/{document}/defects/{document}/defects/{document}

等等...

firebase google-cloud-functions google-cloud-firestore

6
推荐指数
2
解决办法
1580
查看次数

如何在 next.js 中使用 firebase 的 firestore/admin sdk

我正在使用 firebase 和 next.js 构建应用程序

我对这个设置相当陌生,对 SSR 完全陌生,firebase 文档让我感到困惑。

目前,我正在使用 firebase 函数来运行 next.js,这就像一个魅力。但是现在,我想使用firestore。根据文档,我看到了两种在我的项目中使用它的方法(如果我做对了)。第一个是“网络”解决方案,它对我没有好处,因为我相信它不是 SSR,而我的应用程序的全部意义就在于此。

另一个是“node.js”解决方案,它在 firebase 函数上运行,这对我来说更有意义。我无法弄清楚的部分是将它与 Next.js 一起使用

在我当前的设置中,我正在将我的 next.js 应用程序构建函数文件夹中,在函数文件夹中,我可以引用我使用“node.js”解决方案创建的 databaseref 对象,但是如何构建我的下一个应用程序之前引用它? 那么当我不在函数文件夹中时?

设置:

- src
  - utils
  - pages
    - index.js
    - signin.js
    - // etc.
- functions 
  - next // this is the output folder of my 'src' build
  - index.js 
  - // etc.
Run Code Online (Sandbox Code Playgroud)

在里面functions/index.js我可以做:

- src
  - utils
  - pages
    - index.js
    - signin.js
    - // etc. …
Run Code Online (Sandbox Code Playgroud)

firebase reactjs server-side-rendering firebase-admin next.js

5
推荐指数
1
解决办法
1768
查看次数

单击注册按钮时(使用firebase)应用崩溃

每当我在登录页面上单击注册按钮时,应用程序崩溃,并且不会继续进行下一个活动。我已经停留了一天,似乎无法在任何地方找到解决方案。

这是我为注册按钮方法编写的代码。(emailText并且passwordText是TextInputLayout)

 public void signup(View view){
        if(!validatePassword()|!validateEmail()){
            return;
        }
        else{
            ref = FirebaseDatabase.getInstance().getReference();
            ref.child("users").child(emailText.getEditText().getText().toString()).addListenerForSingleValueEvent(new ValueEventListener() {
                @Override
                public void onDataChange(DataSnapshot dataSnapshot) {
                    if (dataSnapshot.exists()) {

                        emailText.setError("Username or Email already exists, pick another!");
                    } else {

                            mAuth.createUserWithEmailAndPassword(emailText.getEditText().getText().toString(), passwordText.getEditText().getText().toString())
                                    .addOnCompleteListener(MainActivity.this, new OnCompleteListener<AuthResult>() {
                                        @Override
                                        public void onComplete(@NonNull Task<AuthResult> task) {
                                            if (task.isSuccessful()) {

                                                FirebaseUser user = mAuth.getCurrentUser();

                                                startActivity(intent);
                                            } else {


                                                Toast.makeText(MainActivity.this, "Authentication failed.",
                                                        Toast.LENGTH_SHORT).show();

                                            }


                                        }
                                    });
                            }
                    }

                    @Override
                    public void onCancelled(DatabaseError databaseError) {

                    }
                }); …
Run Code Online (Sandbox Code Playgroud)

java android firebase firebase-authentication

5
推荐指数
0
解决办法
213
查看次数

Firebase google-services.json 更改不再接收推送通知

最初,我有一个可以运行的应用程序并成功接收推送通知。我在 firebase 中重新组织了我们的项目,我们删除了该应用程序并将其重新添加到控制台(在同一项目中)。我重新下载了该google-services.json文件,并注意到一些事情发生了变化,例如mobilesdk_app_id我正在测试的特定应用程序包。

如果我使用新更改进行全新安装,我可以成功收到推送通知。但是,如果我安装旧版本并google-services.json升级而不先卸载,我将无法收到任何通知。FirebaseMessagingService -> onNewToken我还发现升级后,我没有在方法中收到新令牌的回调。

有办法调试这个问题吗?由于 json 文件已更改,我可以强制 Firebase 给我一个新令牌吗?我从控制台发送这些通知并定位正确的应用程序。我很困惑为什么使用新 json 文件进行全新安装可以工作,但从以前的版本升级却不行。

android push-notification firebase firebase-cloud-messaging

5
推荐指数
1
解决办法
969
查看次数

Flutter:使用从 Firebase 身份验证创建的帐户在 Firestore 中创建用户

我正在使用带有 Firebase 的 dart 语言创建一个 Flutter 应用程序进行身份验证。

我的用户注册代码是

  Future<void> signUp() async {
if(_formKey.currentState.validate()){
  _formKey.currentState.save();
  try{
    AuthResult user = await FirebaseAuth.instance.createUserWithEmailAndPassword(email: _email, password: _password);

    Navigator.of(context).pop();
    Navigator.pushReplacement(context,MaterialPageRoute(builder: (context)=> LoginPage()));
  }catch(e){
    print(e.message);
  }
Run Code Online (Sandbox Code Playgroud)

有谁知道我将如何使用新创建的用户凭据在数据库中为用户创建一个条目?

我已经使用我手动输入的虚拟用户设置了数据库,但希望能够从注册的用户创建条目。

dart firebase firebase-authentication flutter google-cloud-firestore

3
推荐指数
1
解决办法
4327
查看次数

未在 Reactjs 中使用 Firebase 集成 Web 前台推送通知

我在 reactjs Web 应用程序中使用 fcm 进行推送通知。如果 Web 应用程序在后台运行,我能够收到通知。但是当我的应用程序在前台积极运行时无法收到通知。

Firebase 初始化在我的项目中完美完成,因为我在后台成功收到推送通知。

firebase-messaging-sw.js

    importScripts('https://www.gstatic.com/firebasejs/6.3.4/firebase-app.js');
    importScripts('https://www.gstatic.com/firebasejs/6.3.4/firebase-messaging.js');

    firebase.initializeApp({
      'messagingSenderId': '337889493107'
    });
    const messaging = firebase.messaging();

    messaging.setBackgroundMessageHandler(function (payload) {
      const data = JSON.parse(payload.data.notification);
      const notificationTitle = data.title;
      const notificationOptions = {
        body: data.body,
        icon: '/favicon.png'
      };
      return self.registration.showNotification(notificationTitle,
        notificationOptions);
    });
    messaging.onMessage(function(payload) {

      const data = JSON.parse(payload.data.notification);
      const notificationTitle = data.title;
      const notificationOptions = {
        body: data.body,
        icon: '/favicon.png'
      };
      return self.registration.showNotification(notificationTitle,
        notificationOptions);
    });
Run Code Online (Sandbox Code Playgroud)

我需要对我的前台方法做任何进一步的修改messaging.onMessage还是需要做更多的配置。请帮帮我

javascript firebase reactjs firebase-cloud-messaging

1
推荐指数
1
解决办法
1008
查看次数