Как на стороне клиента, так и на стороне сервера подписать пользователя на топи c, разница в том, что на стороне сервера вы можете подписать много пользователей на одну и ту же топи c:
// These registration tokens come from the client FCM SDKs.
var registrationTokens = [
'YOUR_REGISTRATION_TOKEN_1',
// ...
'YOUR_REGISTRATION_TOKEN_n'
];
// Subscribe the devices corresponding to the registration tokens to the
// topic.
admin.messaging().subscribeToTopic(registrationTokens, topic)
.then(function(response) {
// See the MessagingTopicManagementResponse reference documentation
// for the contents of response.
console.log('Successfully subscribed to topic:', response);
})
.catch(function(error) {
console.log('Error subscribing to topic:', error);
});
Вам нужно использовать topi c, который не содержит /
:
FirebaseMessaging.getInstance().subscribeToTopic("news")
или
admin.messaging().subscribeToTopic(user.messaging_token, 'news')