How to send notifications to one of two apps in the same project at firebase

前端 未结 4 728
遥遥无期
遥遥无期 2021-01-15 01:08

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 ap

相关标签:
4条回答
  • 2021-01-15 01:23

    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

    0 讨论(0)
  • 2021-01-15 01:31

    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

    0 讨论(0)
  • 2021-01-15 01:32

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

    0 讨论(0)
  • 2021-01-15 01:38

    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

    0 讨论(0)
提交回复
热议问题