design – Broadcast on all devices or use topics?

We have hundreds of thousands of users and we need push notifications for specific groups of people, to all their devices. We have about 5000 groups. Each user of a group has notification preferences, he can choose to include or disable a specific type of notification. Let's say we have 20 types of notification. To do this we need to use SNS and Firebase. As far as I know, SNS and Firebase do not have message filtering, and doing it on the mobile device is not something I would do.

What would be the best option in terms of speed and durability to deploy each device individually or to create a topic by type of notification, by group?