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

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)

Related

Firebase Push Notifications and Flutter Local Notifications

I've implemented Firebase Push Notifications using Admin SDK for both android and iOS. In iOS i'm receiving notifications on all the stages (Foreground, background or even terminated), but in android I need to integrate Local Notifications again for receiving when app is in foreground. Even I'm successfully integrated it. I need to maintain single notification for particular user. I'm using TAG field while generating Push Notifications whereas in the frontend even i provide the same tag its generating a new notification. So I've added tag as notification_id by converting it to HASHCODE. Now I'm receiving unique notifications using Local Notifications as well.
My problem i'm facing is
For instance consider when my app is in foreground I've generated notification using Local Notifications Package. In the next minute I went to background so I've generated Notification using firebase SDK. In this case I'm seeing 2 Different Notifications for the Same User. One from Local and another from Firebase. In need to maintain single notification for particular user.Can anyone guide to how to solve this.

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.

Send FCM Token to Specific App of a Project

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.

Push adapter for more than one Worklight Application

Is it possible to create one Workight Push adapter for more than one application in the same Worklight Project ?
if it is faisable how do I configure my project because I think that the push notification is recognised by the application name in the Android environment. So the push Handle will work just for the first application but not for the others.
Any idea ?
Push notifications are not per application name. Why do you think this? Did you see it somewhere in the documentation?
See these topics:
Push notifications
Sending push notifications to the device
What you could do is either write very generic code and make sure your subscriptions are unique to the app so they won't overlap and send a notification to both apps, or use multiple Event Sources - one for each app?
The entity you declare in you adapter called EventSource. Any number of applications can subscribe to this event source. Now, the limitation is you'll be able to receive push notifications only in the app you've subscribed to push with. E.g. if you subscribed with app1 you'll be able to receive notifications with app1 only. In case you need to receive push notifications in app2 you'll have to subscribe separately. However there is nothing preventing you to use same EventSource (adapter) in both apps.
I resolved this issue by creating 2 Push Adapters, in each one I created an event Source.
After that,I created 2 applications in the same Worklight project, each one subscribes to a different Event Source but the both of them have the same pushSender configuration in the application-descriptor.xml file (same key and same senderId)
Notice that when created 2 event source in the same Push Adapter, the deployment of the adapter always fails, so that's why I created an separate adapter for each event source.

Categories

Resources