3

We have multiple apps at the same project of firebase like Master, Develop, testing.

And for sure every one of them has different users and we want to send to one app and not reach to other apps as all of them have the same topics how to solve this issue?

KENdi
  • 7,576
  • 2
  • 16
  • 31
Sattar
  • 2,453
  • 2
  • 33
  • 47
  • Well, it's depend on "where is the users data"?. –  Aug 10 '17 at 08:47
  • i use firebase for notifications not anything else so how it will depend on data ? – Sattar Aug 10 '17 at 08:50
  • If you are using firebase for notification only, then you can specify which application will receive the notification or which user will receive it, By handling this issue in the backend, "I assume there is a database for each application". –  Aug 10 '17 at 08:54
  • It's not recommended to have multiple apps in a single project that represent different environments. It is recommended to have different projects for each environment. – Doug Stevenson Aug 10 '17 at 08:58
  • yes for sure every one have database but they have the same firebase project so how to differentiate between them while we don't use tokens we use topics that already created – Sattar Aug 10 '17 at 08:58
  • There is only one database shared by all apps in a single project. If you want a different database for each app, each app needs to be in its own project. This is the recommended way to organize your environments. – Doug Stevenson Aug 10 '17 at 09:01
  • @DougStevenson so when i have multiple projects so i will have multiple projects too in android studio and any change done in one i must copy and paste into the other ? – Sattar Aug 10 '17 at 09:01
  • Read this blog post to understand how it's supposed to work: https://firebase.googleblog.com/2016/08/organizing-your-firebase-enabled-android-app-builds.html – Doug Stevenson Aug 10 '17 at 09:02

4 Answers4

2

You could filter the notifications in each app by a given identifier which you attach to the notifications.

Matthias Bruns
  • 899
  • 8
  • 13
1

Lets say you currently have Apps: A, B, C All registered to:

  • A: registered to FUN topic
  • B: registered to FUN topic
  • C: registered to FUN topic

All you need to do is to register them to another topic individualy for identifying them, like this:

  • A: registered to FUN topic and to APPA topic
  • B: registered to FUN topic and to APPB topic
  • C: registered to FUN topic and to APPC topic

Now you can target the notification to be sent with a condition causing the notification to be targeted specifically to whatever you want, the following example targets notifications to whoever is subscribed to topic: FUN and APPB:

https://fcm.googleapis.com/fcm/send
Content-Type:application/json
Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA
{
  "condition": "'FUN' in topics && 'APPB' in topics",
  "data": {
    "message": "This is a Firebase Cloud Messaging Topic Message!",
   }
}

more on this can be found in this Firebase documentation page

Mercury
  • 7,430
  • 3
  • 42
  • 54
1

You can use the restricted_package_name parameter (if your master, develop and testing have different package names) to filter the receivers by package name.

To highlight @Doug Stevenson's comment. It is not recommended to put these three environments in one project

gerardnimo
  • 1,444
  • 8
  • 10
1

after a lot of search i didn't got an answer from firebase side to differentiate between 2 apps so i just made a condition into background message service and know if the app is develop or master version and then push the notification if it's my correct version

Sattar
  • 2,453
  • 2
  • 33
  • 47