Sending notification to multiple devices without using subscribeToTopic in firebase - android

I know how to send notification to single user and multiple users by using subscribeToTopic ("all"), but how can I send Notification to a group of people according to my wish

To solve this, use Cloud Functions for sending notifications. You can send a notification to a single user or to a group of users according to your needs. I've exaplained the entire flow for doing this in my answer from this post. So a notification can be sent, even if the user has not opened the app. He will receive the notification every time something interesting happens.

Related

Can I set the "Difference push receive setting in firebase?"

I am now trying to make a mobile app push notification service on Firebase. But the function description is not quite specific as I expected.
I want to know these functions are available on Firebase. If not, It would be pleasure If you tell me other tool.
User can select the push message types they want to receive.(Ex. Receive sale information push, Do not receive game event push)
Instantly send auto push messages when user triggered certain condition.(Ex. Send appreciate push message when user closed their first app-open)
Thank you
Can not tell in much description here:
1. User can select the push message types they want to receive.(Ex.
Receive sale information push, Do not receive game event push)
You can use FCM's channeling feature,
You can set different channels.
Show the list of channels to user.
User can subscribe to the required channel.
User will receive the specific channel notification only.
Please refer : Notification Channel
2. Instantly send auto push messages when user triggered certain condition.(Ex. Send appreciate push message when user closed their first app-open)
You have manage this thing in your front end and backend logic.
Like on app close send request to the backend (can use onDestroy method )server and then the backend server will send notification.
Hope this will help you.
For Feature 1:
You can achieve this without even doing anything. Just send all notifications to everyone. However, use different Notification Channels. Users, can then choose to turn on/off certain notification channels using the Android system features (in relatively newer versions of android).
Another way could be to send these notifications to different FCM Topics. Give the users a settings pages, where there can select what kinds of notifications they would like to receive. In response to their selections, subscribe or unsubscribe them to the respective FCM Topic.
For Feature 2:
There could be several hundred ways of doing this. Can provide better advice if you could provide more information about your requirement.
If you talk about your example requirement
(Send appreciate push message when user closed their first app-open)
You can do it without any server, or push messaging scheme. Just keep track of the first_open event inside the app using Shared Preferences. Once you detect a first_open event, just compose a notification inside of the app locally, and show it whenever you like.

FCM push notification to all devices which will be filtered on client side

Okay, I know the question may sound stupid. I’m building an app where there are pages that publish posts and users can subscribe/unsubscribe to those pages.
The goal here is to find a way to send notifications whenever a new post is published but only to the subscribed users. I though that I can do this by sending a push notification to all the devices on my app whenever the “Posts” reference is updated on Firebase database, and then choose whether to show this notification or not if the user is subscribed (on client side)
Is this a good idea? And if yes, how can I accomplish that?
Is this a good idea?
Yes, the idea is not bad. However, filtering notification to be shown in client side is done in many cases.
And if yes, how can I accomplish that?
I hope you already have a login or authentication system using Firebase authentication or any other server side authentication. When you have this, you might have already considered sending a push registration id to your server or firebase when a user signs up in your application and save it in your firebase database.
Now when its time to send a push notification, you are planning to send the push notification to all of your registered devices and you want to filter the notification will be shown or nor in the client side.
This can be achieved by keeping a flag in the client side, for example a SharedPreference having the id or tag of the last post. If you have an incremental id for each post, then it will be a lot easier to implement. When a user launches your application, it pulls the posts from your firebase database as I can think of. Just save the latest id of the post in your SharedPreference and when a push is received, match the id of the post that came along with the push notification with the latest id stored locally.
If the id received via push notification is greater than the id stored in your SharedPreference, you will show the notification in system tray and the notification will not be shown otherwise.
Hope that helps.
You can push notification to only subscribed users if you are maintaining a list of subscribed users FCM token in your database
Your approach is correct, what you would need to do is that maintain different database tables for all pages where users are inserted when they subscribe to that particular group/table.
So, let's suppose when a person subscribes to the page containing information about Sports, you add him to that group. Later, when you are sending update/notifications related to 'Sports' you would only send those push notifications to the user-tokens in 'Sports' table.
In this way, only relevant subscribers would receive those push notifications.

Send android push notification to all except one user [duplicate]

This question already has answers here:
Push notification to all the users subscribed to the topic except login user using FCM Firebase
(2 answers)
Closed 4 years ago.
I am using firebase and I have an application where I need to send notification to all users. So to achieve that I have created a topic allUsers to which every device subscribes. Now if I send push notification to this topic, every device received it. I want to exclude one device, which is indirectly creating push notification to /topics/allUsers.
Is this achievable.?
Update:
For Android, what I do is, I include a sender custom value in the payload, check if the value is the same as the current user's id, if it is, I don't show the notification.
Topics Messaging works simply that all subscribers would receive the message sent to the corresponding topic.
You can't exclude a specific subscriber. You're going to have to:
create a separate topic where the user won't be subscribed
unsubscribe the user to the corresponding topic
or send the message to the specific users only using registration_ids instead
Other than that, there is currently no other workaround on what you want to do.
Might be a little late, but after reading Frank´s post, I came with the idea to create your topic for all users and then a topic for each user, then when sending a message, you can add topic conditions such as:
('AllUsers' in topics) && !('user_foo' in topics)
Yes, you can do this. Go to your Firebase console, click on your project panel and there navigate to Grow/Notifications tab. There you can send messages (push notifications) to your app users and adjust everything related to the message and targeting there:

Group Firebase FCM on Android Device

I am trying to send cloud messages using the Firebase console. I am doing this for android device.
The push notifications do appear on the device fine along with the data sent with it.
But each notification shows up on its own. Meaning if I send 3 notifications three items show up in the notification bar.
What I want to achieve is that all the notifications to be grouped under one heading. As you have in WhatsApp or Facebook.
How can this be achieved using the Firebase Console?
By grouping the notification, do you mean stacking or bundling notifications?
If so, this is actually depends on how you handle notifications in your client app. You simply have to make use of the setGroup() to add all your notifications to a single group then calling notify() to let the NotificationManager of the changes.
This Add Each Notification to a Group documentation pretty much sums it all up.

Limit Sending Push Notification (Prevent Spam) - GCM

Well I have an android app like social network,I m using GCM, to send push notification,
When a User A follow User B , User B will receive notification saying "that User A has started following you".
Now I'm trying to prevent abusing/spamming sending multiple push notification.like follow and unfollow follow again and so on.
What is the best approach to tackle this problem .because I don't want my users to get abused receiving multiple notifications.
I've tried to look for a perfect solution regarding this issue.Unfortunately I can't find any answer.
You can send notification to user just one time for follow and for unflallow, Then you should not send any notification for that , because it is not valuable information.

Categories

Resources