Send FCM Token to Specific App of a Project - android

I have created one project in my Firebase Account. In this project, I have added two android apps.
Now, while sending push notification through Firebase console, I see the option of selecting my individual app as shown below
But, while sending notification through Postman, I don't know how can I send notification to only a particular app?
Should I create two individual project for both my apps, so that the server key is different?
But, I feel there should be a way to send notification without creating multiple projects for multiple apps.

Sending notifications to user segments is not available programatically i.e. not available when using the API.
A workaround you could use is Topics Messaging, creating a topic for the specific app and subscribe the corresponding users.

Related

Should i use multiple firebase projects for different customers but the same app or only one for FCM?

I want to add push notification to my app with Firebase Cloud Messaging but i don't know the right way to set this up.
My app looks like this:
I have multiple customers (companies) who host their own server with a database for their employees.
Every employee of my customers will download the app to receive push notifications from their company's server which implements the firebase admin sdk to send push notifications.
I thought the easiest way would be to let every customer set up their own fcm project and then add the api key to the app.
This is easy to set up in android, but in ios every company would need an apple dev account for the certificates which costs them 99€ every year just too receive push notifications.
So maybe only i need to set up one firebase project myself and generate a server key for every customer. This way only i need a apple dev account.
Is it possible to let every customer send push notifications through my fcm project to their employees but not to any other employees of different customers. They should not be allowed to see any data of other customers or send messages to them.
What's the intended way to set this up and is there a limit to push notifications in one firebase account? If only i host a fcm project for every customer i might hit the limit.
Thanks in advance for your help.
They should not be allowed to see any data of other customers or send messages to them.
If you require isolation between customers, then they should definitely not be using the same project. They should be in different projects, so they can't send messages outside of their own user base.

Firebase FCM, multiple apps in the same firebase project

I have a Firebase project in which I registered multiple apps.
now I want to add push notification, and I want to be able to distinguish which app should wake up by the push notification.
in the google-services.json file, I see that all the apps have the same value for the current key in api key section, I understand it is because I registered the apps in the same Firebase project.
I also read about the SERVER_KEY, and saw that there is an option to add SERVER KEY. can I add multiple server keys and use them in my server, in order to send the push notification for the correct app?
or is there any other solution that allows me to keep the apps registered in the same Firebase project but distinguish which app should wake up by the push notification?
Yes, You can use multiple apps within the same project, you can use the firebase data structure to distinguish between apps:
(Use it as using channels)
https://www.firebase.com/docs/web/guide/structuring-data.html
With that said, from my experience, this is not recommended. At iOS platform, when multiple apps on the same device shared the same firebase keys, it caused some strange behavior for me, so my advice would be to open a new project per app (Pretty sure that is the documentary best practice too) Android worked fine.

Is it possible to target multiple apps with firebase, but only one will display the notification

I am new with FCM and I am still discovering its possibilities.
I wonder if it is the right tools to do what I want:
I would like to send a notification to all my users, to inform them about new informations for example.
The difficulty is that I want to target all the users of different apps (like 10 apps), and some of them may have more than one of my app installed.
So I do not want a user to have the same notification displayed multiple times (if he installed more than one of my app).
Is it something possible with Firebase?
Thank you
Yes you can! To achieve this, i recomand you using Google Cloud Messaging not FCM. which it's an earlier version. Here is a tutorial on how you can migrate from FCM to GCM.
To achieve this, all your 10 apps must use Firebase and all your users must be Firebase registered users. To send a notification to all devices, would mean then to select all the registration ids from that database, add them in an array and pass them further to GCM.
Note also, that strating with GCM 3.0 it's now possible to send a notification to all devices thanks to topics support. The app must suscribe to one or more topics and the server can send notifications to that topic without specifying individual devices. You can see here Topic Messaging.
Unfortunately, there is no way in which, with a single line of code, to send a notification to all of your users from all your apps. You can only send a notification to all your users that belong only to a single app. If you want that all of yours to get the same message, then you need to consider sending that particular message again, to all users that belong to each app. In this case, if a users is using more then one of your apps, will receieve that message for each app separately.

Android: Sending same notification to multiple apps install in one device

I am working on multiple apps having Firebase notification library. I will be using third party portal to send notification.
Suppose I want to send one promotional notification to all my apps and one device is having my 3 apps install. Now all 3 apps will show the same notification. How can I avoid this scenario.
Also, I have created one library to generate notification according to json received.
When I get notification, I am sending data to this library. This library is added in all my apps.
Can any of following help
1: Handling from backend- Creating one firebase project and adding multiple
apps.
2: Reading notification id in library which will generate notification and checking if any notification is already generated for the id.
As there is no way of finding out if one or multiple apps are install on one device, I have to send notifications to all apps.
With simple notifications, you can't: they are generated automatically by the system.
You'll have to send data messages and implement a logic to check whether any other of the 3 apps is installed and generate the notification only from 1 app (prioritize)

Testing Googles Firebase Notifications on Development Device Only

I am working on an android app where I want to be able to use the notification system within Firebase. I want to use the advanced features where I can add key/value pairs so that I can implement the notifications to do different things under certain conditions when clicked.
I obviously only want to test this on my test/development devices but can't see a way to do this.
You should choose single device choice on "send notification" screen.
After that you should get your FCM registration token. Yo can get token via this app.
https://play.google.com/store/apps/details?id=com.tune.mytunedevice
Write your token and send notification.
You could create a new product flavor for your app (e.g. "development") (Configure Build Variants) and create a seperate firebase project (with a seperate google-services.json file) (Add multiple google-services.json files).
Then you have different API keys for each project which don't effect each other.
You can get the FCM registration ID for those testing devices and send the message just for them, or create a topic/testing and register those devices to that topic then send the message just for this topic.

Categories

Resources