Subscribe to Topics

Optionally subscribe the user to one or more topics to target multiple users with a shared interest when sending notifications.

Depending on your app's notification criteria, you may be able to leverage topics to simply the process of sending the same notification to multiple users. If your app only sends personalized notifications, skip this step and simply target individual users by their unique device tokens.

Please select your Android project type for the appropriate instructions:


Simply add the following blocking code to subscribe the user to a topic:

Pushy.subscribe("news", getApplicationContext());
Pushy.subscribe("news", applicationContext)

Note: Make sure to execute this method from a background thread, similar to Pushy.register(Context).

Also, replace news with your own case-sensitive topic name that matches the following regular expression: [a-zA-Z0-9-_.]+. You may also pass in a String[] array with multiple topics.

You can then notify multiple users subscribed to a certain topic by specifying the topic name (prefixed with /topics/) as the to parameter in the Send Notifications API.