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.
Related
I am using the Firebase Cloud MessagingPush notification service to send notifications in flutter but I want to send notifications at a specific time like a reminder for a meeting through push notification I just want to know how can I achieve using Firebase Cloud Messaging or any other push notification service provider.
I already used flutter local_push_notification but the problem is notification is not showing at terminated state but it is working on the background and foreground state.
is there any method is available that I can use on my server where all my API is presently saved, which I using to call in a flutter.
You can use firebase cloud functions. You should send notifications at the moment you want with cloud functions and problem should be solved.
Here is the docs.
I am creating mobile application using latest version of Ionic 3. And I am at the point where I need to implement push notifications. I am using FCM. I have managed to done it for Android phones using this plugin: https://github.com/phonegap/phonegap-plugin-push. Reading documentation for this plugin, it says that for Android I should send only Data Messages and that that is the best practice. It also says that send Notification and Data payload would not work properly:
When your app is in the foreground any on('notification') handlers you have registered will be called. If your app is in the background, the notification will show up in the system tray. Clicking on the notification in the system tray will start the app and your on('notification') handler will not be called as messages that have notification payloads will not cause the plugins onMessageReceived method to be called.
But for IOS I need to send notification message with data payload. This would not be a problem if I target directly devices, however I need to send Topic Messages. So the way I see is that on my server I need to implement this logic:
Let's say that the name of topic is FOOD-AND-DRINKS:
function onSomeEvent($data) {
// send push notification to topic ANDROID~FOOD-AND-DRIKS
// send push notification to topic IOS~FOOD-AND-DRINKS
}
Also, since in the future my plan will include multiple cities, and not all people would like to listen for notifications for cities other the one where that person lives, so then my topic would be PLATFORM~CITY~CATEGORY.
So my question would be, is there any better plugin for handling notifications, or some service between my server and Google FCM and that service would take care of that, or this is quite OK what I have proposed?
You can use cloud functions to be able to send notifications since you are using FCM also.
More on this here: https://firebase.google.com/docs/functions/
Cloud Functions for Firebase lets you automatically run backend code in response to events triggered by Firebase features and HTTPS requests. Your code is stored in Google's cloud and runs in a managed environment. There's no need to manage and scale your own servers.
Using cloud functions you can use database triggers like onWrite() and it will be able to send notifications if you have data payload and/or notification.
But if you use data payload alone then you can send if android device is in background also.
Regarding Topics:
If you have multiple cities in your application, then you can let the user register to each topic. You can do in the database like this:
city-category
id_here
cityname: nameX
//other details
id_here1
cityname: nameY
//other details
I have an Android application developing in Java and using Firebase Database. This application will send the notification to the users when uploaded something to the database. Therefore, I want to ask whether can the application send push notification using MQTT instead of using Firebase Cloud Messaging(FCM)?
Therefore, I want to ask whether can the application send push notification using MQTT instead of using Firebase Cloud Messaging(FCM)?
You can use whatever you want. There's no requirement to stick Google service for this.
I want to notify android users(students) whenever they got failing grades. I tried using Firebase notification, but what I can do about it is to manually type messages in my firebase account and send it to users. I want to send notification to specific users automatically depending on the condition in my codes. Thanks in advance.
I suggest you to start with Firebase Notification
Less code and reliable
You can start with code sample
https://firebase.google.com/docs/samples/#android
and find the Cloud Messaging sample
You can also archive this by using Realtime Database that will provide data changed listener every time data is added/updated. And you can take this advantage of the listener to notify your Notification in Android
The latest launch of Firebase notifications feature allows to manually give the time and content of notification. Is it possible to automate it so that notification is received every time a particular variable is changed in the Firebase database?
Thanks for the reply Hamid. I didn't want to get into the technicalities of GCM therefore I implemented the notifications using a service. This service listen on the Firebase database and sends a notification whenever new data is added there.
I think you would have to setup a GCM (Switched to FCM now) server that handles all that. But I also do wish that there was a simple way of setting that up without needing to build a full server.
There is a friendlyping application that helped me set the XPMM server.
I think the current Firebase Notifications are very much in its early days. It doesn't provide many of the functionalities of Batch.com or Parse Server... yet.