【问题标题】:How to restrict FCM push notification to application id?如何将 FCM 推送通知限制为应用程序 ID?
【发布时间】:2019-07-04 08:04:43
【问题描述】:

我在firebase中创建了一个项目,并在里面创建了两个android应用程序。

但如果我使用 Admin SDK 发送推送通知,通知会发送到两个应用程序,我们如何才能将通知限制为仅单个包?

我的通知格式如下:

var message = {
    notification: {
      title: 'Test title',
      body: 'Test body',
    },

    android: {
      ttl: 3600 * 1000,
      notification: {
        icon: 'test_icon',
        color: '#f45342',
      },
    },
    topic: topic
  };

【问题讨论】:

标签: android node.js push-notification firebase-cloud-messaging firebase-admin


【解决方案1】:

感谢@ADM 的提示。 我们可以使用restricted_pa​​ckage_name 并指定我们的应用ID,以限制特定应用的推送通知。

消息格式应该是这样的:

var message = {

    notification: {
      title: 'Test title',
      body: 'Test body'
    },

    android: {
      restricted_package_name: "com.mycompany.someapp",
      notification: {
        icon: 'test_icon',
        color: '#f45342',
      },
    },

    topic: topic
  };

它应该在 android 键中,因为 restricted_pa​​ckage_name 仅适用于 android。

【讨论】:

  • 是的restricted_package_name,这将解决问题。
  • @Prajeet Shreshtha iOS 呢?我们也可以限制相同吗
猜你喜欢
  • 1970-01-01
  • 2021-06-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-12-13
相关资源
最近更新 更多