Search code examples
androidfirebasefirebase-cloud-messaging

how to use firebase admin java sdk to segment country and send notification?


I can use firebase admin java sdk to send notification which device can receive android notification successfully, but I need to simulate like firebase console to segment country or app version to send notification. I found the com.google.firebase.messaging.Message.java class, I also checked the github test demo which can set condition in message like device.os == 'android' && device.country in ['us', 'uk'], but it throws invalid condition argument exception. How to fix this problem?


Solution

  • The functionality to target a group of user based on their country or other attributes is only available in the Firebase console. There is no public API for Firebase Cloud Messaging for this.

    If you want to target users based on their country or other attributes through an API, you'll have to build that targeting logic yourself. You can either have the app subscribe to topics that match the attributes of that user, or build the targeting on the server based on attributes you have available there.

    Also see: