'Firebase data message to specific android app versions

i have an android app and i want to send a firebase data message to inform the users of a new app version available in the play store. I am sending a data message in order to reach devices in which the app is in background. I want send the message to specific versions, or if it's possible to all versions except the last version. What is the best way to do it? Can I specify a version number in a fcm data message? Below is the data message i am sending.

Thanks in advance.

{
  "to": "/topics/all",
  "data": {
    "title": "new version",
    "body": "a new version is available in play store"
  }
}


Solution 1:[1]

I don't have answer for your question but I can suggest another way to achieve your case. Take a look at Firebase Remote Config.

You can define variable for your client to get anytime it start. So for your case, we have 3 variable:

destinationVersion for your specific version

title

message

In the app, just put the logic like if app's version equal to destinationVersion , create a notification with title and message to tell user update the app . Hope it helpful to you.

Solution 2:[2]

You can force users to update with Google now: https://developer.android.com/guide/playcore/in-app-updates#immediate

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ToraCode
Solution 2 Netuddki