The code snippet I wrote earlier is a simplified example of a more complex problem. The inclusion of multiple "topics" per company is not sufficient to solve the problem, because in my case, in addition to having different companies, each company has one or more user profiles enabled to receive firebase messages. So the system should, after receiving the message, check if it is intended for the selected user profile and only then notify it. This is why I was wondering if a way to handle firebase messages was possible.