【问题标题】:FCM push notification is not being shown on the active web deviceFCM 推送通知未显示在活动 Web 设备上
【发布时间】:2021-09-13 03:51:54
【问题描述】:

我在使用 FCM 发送推送通知时遇到了一些意外问题。我已经在我的电脑和移动设备(网络)上登录,当我点击负责事件触发的按钮时,通知会弹出但不会在活动设备上。如果我使用手机点击按钮,通知会在我的电脑上弹出,而不是在手机上。同样,当我使用计算机执行此操作时,我可以在手机而不是计算机上看到通知。 这是一个问题还是它应该是这样的? 我在我的 Nodejs 服务器上使用 firebase-admin SDK。

提前谢谢你:)

【问题讨论】:

    标签: node.js firebase web firebase-cloud-messaging firebase-admin


    【解决方案1】:

    推送通知仅在您的应用不在焦点时显示。如果您使用您的应用程序发送推送通知,您将不会在那里看到它。您仍然可以使用这种代码构建自己的逻辑来处理传入消息,同时您的应用程序具有焦点:

    // Handle incoming messages. Called when:
    // - a message is received while the app has focus
    // - the user clicks on an app notification created by a service worker
    //   `messaging.onBackgroundMessage` handler.
    messaging.onMessage((payload) => {
      console.log('Message received. ', payload);
      // ...
    });
    

    您可以阅读更多关于它的信息here

    【讨论】:

      猜你喜欢
      • 2018-08-27
      • 2017-04-27
      • 1970-01-01
      • 1970-01-01
      • 2018-03-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-23
      相关资源
      最近更新 更多