Real-time database triggers Firebase notification vs. FCM - android

I see here is event triggers https://firebase.google.com/docs/functions/database-events for RTDB and I watch onCreate() method.
onCreate()`, which triggers when new data is created in the Realtime
Database.
When I create new insert into RTDB in this method I can notify user about new insert into database.
But my question is now I can make here notification and all mobile device in same time get notification?
Why I need to use FCM. With FCM I can choose which mobile device get notification and many more features about notification?

The Firebase Database client in your app is (normally) only active when the app is running and in the foreground. So it can only receive the new data, while the user is actively using your app.
The Firebase Cloud Messaging SDK includes a service that is also listening for messages when the app is not in the foreground. That means that with FCM you can also notify the users when they are not actively using your app.
It is quite common to use a combination of the Firebase Database and Cloud Messaging:
If one user changes the state, write that change to the database.
Then use FCM to notify the other users that "something" has changed.
Finally when the other users open the app again, the app gets the latest state from the database.

Related

Android notification Screen

I'm creating an ecommerce app and I want to send promotional notifications to users from firebase cloud messaging. I want to show all the notifications in recycler view in notification screen using adapter can anyone tell how do I save all incoming notifications and display them in notification screen
If you want to show all notifications you need to save those in
local database when you receive and fetch all on required screen.
You can use Room database for the same.
You can ask the backend developer to save all notifications at
backend side and fetch those by an API.
Approach 1
See If you are sending a notification from the firebase console, Then you need to save that notification in the local DB While It receives in Mobile Firebase Messaging Service Class. (but It's not a good approach, Because user loss notification in case of clear data for app or reinstall app)
Approach 2
If you are sending notifications using some API or firebase function Then you can create one collection of Notifications and save notifications every time while sending And Fetch notifications from the same collection.

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

Programmatically fire push notification from Azure web service?

I'm using Azure for an Android mobile app backend. I have my app service, a server and DB, as well as a notification nub. I've already got the notifications firing to the device properly when press "Test Send" in the Azure dashboard, but I'm trying to listen to the database and whenever a new entry appears in a particular table I want the user to recieve a notification with that information.
I can't seem to find any commonplace way to do this directly in the Azure dashboard offered by any service.
There isn't anything you can "auto hook up" to be notified of a database table change in Azure App Service. You'll have to code up a process in your application to periodically check for new entries in your database and then fire off the notifications. To do this you can either use a Continuously Running Web Job, an Azure Function, or even an Azure Logic App connected to your database and Notification Hubs.

Background notification with firebase on database update

I want that firebase sends a notification to my app when my database is updated. For example when I write a new entry in this database, the app should receive a notification, even if the app is closed.
Since you are using Firebase I would suggest you to use the feature Cloud Messaging. You can send a Data Message and the application knows that the database was updated. Check more info about it here: https://firebase.google.com/docs/cloud-messaging/concept-options

Firebase notification on child added/modified

Is it possible to generate a push notification (if the app is not in the foreground) on firebase db changes? I started coding an android app.
Firebase provides a tool called Cloud Functions.
With this, you can listen to your Firebase Database and send Notifications without the need for an external server :)
See : https://firebase.google.com/docs/functions/use-cases
To do it in a simple way, you can use a Service, in this Service you can set a Listener on a ref in your firebase DB when the event is triggered you can create a notify and show it to the user.
This is a very simple tutorial:
https://www.simplifiedcoding.net/android-push-notification-tutorial-using-firebase/
There certainly is. Just have your Android app write the notification request into the database.
Sending device-to-device notifications is not a supported scenario in Firebase Cloud Messaging (see this answer), so you'll need a server component for that. For an example of how to send a push notification in nodejs, see this answer.

Categories

Resources