Automatic send Notification triggers in every button clicks - android

I'm currrently working with an android app that provides news, announcements and events updates.
Now I want to send notifications to all app users that there is a new announcement and when they click it they will go to announcement activity.
This is the announcement activity
This is I add announcement
What I want to achieve is, every time that the user (the one who create the announcement) click the button which is "Upload" it will trigger the app to send notification to all the users of my app. if possible I want it to be automatic no need to go to firebase but if it is impossible I'm okay with anything.
I just need an idea how to make it so I will follow but I would be so happy if someone could provide a sample code.

You should do this on the server side. The service that saves the announcement in the data base, can also send an FCM notification to a topic.
You can use the FCM HTTP V1 API to send notifications.

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.

Sending notification to multiple devices without using subscribeToTopic in firebase

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.

take back the Firebase notification on the server side

In my web app I notify a group of users using FCM. When the first user reacts to the notification, the others loose the chance to respond (Say it is a game).
I want to take back the sent notification to other users and It is obvious that I can not implement the logic inside the android app (Because only the server knows who won the game).
Is there a way to take back the notification sent using Google Firebase on the server side?

sending a push notifiacion by on click button firebase

Is it possiable to set an on click button which will send a push notifiacion message to a user on fierbase? I seccssed sending a push message by the website but I really need the option to send messages from the app.
Thankds!
You can do it now with Functions. This means it is perceived as if were done by the app, but it is a longer way.
For start, there is no such a thing as an app to app Firebase Cloud Message, is very confusing because the Firebase Database is real time.
What was done before Functions, was to make the app trigger something on a server, and then the server will make FCM send the push notification.
Now with Functions, you don't need a server. Functions can listen to changes in the Firebase Database (also can listen to user creation) and can send Firebase Cloud Messages. So the complete flow is this:
The app will trigger a change in the database
Functions will be
listening to that node
When the changed has listened, then a push
notification will be triggered
If it is needed, Functions can
request data from other nodes, to get the device token by example
This is the Functions documentation https://firebase.google.com/docs/functions/
Currently, Functions is in beta so, please see the samples here https://github.com/firebase/functions-samples
And here is a personal sample, which is heavily commented to clarify all the problems which I went https://github.com/cutiko/testing-functions
Good luck

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