2

我在我的Node.js项目中发送了FCM集成,我向IOS用户发送了一些通知,我需要管理通知计数,即徽章计数在整个设备中会有所不同,但我正在向特定主题发送通知给这些设备被订阅。有没有办法将不同的徽章数量发送给同一主题中的不同用户?

我的有效载荷是:

var payload = { 
      notification: { 
       title: "Title...", 
       body: "Notification Body...", 
       sound: "customeSound.caf", 
       badge : "?" 
      }, 
      data: { 
       testData: "custom data" 
      } 
     }, 
topic = "topicName"; 

     admin.messaging().sendToTopic(topic, payload) 
      .then(function (response) { 
       // See the MessagingTopicResponse reference documentation for the 
       // contents of response. 
       console.log("Successfully sent message:", response); 
      }) 
      .catch(function (error) { 
       console.log("Error sending message:", error); 
      }); 
    }); 

回答

1

订阅了相应主题的所有设备将收到您设置相同的有效载荷。

您必须为每个设备发送单独的有效负载。或者,如果适用,也许只是将具有相似badge价值的那些分组 - 但这需要您发送到一组令牌(使用registration_ids),而不是发送到主题。

+0

感谢您的答复@AL,但这是我不想使用,我已经接近FCM。如果我将通过APNS ID进行分组,我将使用本地APNS系统。 –

+0

嗨@aatifshaikh不幸的是,如果您继续使用FCM,这将会如何。 –

+0

:(谢谢反正@AL。 –

相关问题