首页 > 解决方案 > FCM 从主题退订特定令牌

问题描述

我现在面临的问题是,我有 FCM 主题并且这个主题有很多订阅者我希望管理员从主题中删除用户而不是这个用户自己取消订阅。

标签: flutterfirebase-cloud-messaging

解决方案


YOu can use firebase-admin. YOu just need to get the users' fcm tokens into an array then pass in the array of user tokens you would like to

// These registration tokens come from the client FCM SDKs.
var registrationTokens = [
  'YOUR_REGISTRATION_TOKEN_1',
  // ...
  'YOUR_REGISTRATION_TOKEN_n'
];

// Unsubscribe the devices corresponding to the registration tokens from
// the topic.
admin.messaging().unsubscribeFromTopic(registrationTokens, topic)
  .then(function(response) {
    // See the MessagingTopicManagementResponse reference documentation
    // for the contents of response.
    console.log('Successfully unsubscribed from topic:', response);
  })
  .catch(function(error) {
    console.log('Error unsubscribing from topic:', error);
  });

where the registrationTokens are the user tokens and topic is just String of the topic you would want to unscribe the user from.

check out firebase documentation below on the topi

I hope this helps out. If you are still stuck let me know.


推荐阅读