Schedule exam date and time notification in Firebase Application - android

I want to implement functionality in the application on which user can schedule their exam on a particular date and time. and I want to generate notification before one day ago, so users will get reminded about their exam. I am using Firebase Database.Should i use Alarm Manager for that? or any background service ?
I don't have any idea about this. so can anyone help me how to implement this?
any help would be appreciated. Thank you.

One possibility would be to use Firebase Cloud Messaging (https://firebase.google.com/docs/cloud-messaging/) together with Cloud Functions.
You would write an HTTPS Cloud Function that would be triggered regularly (e.g. everyday in your case) and that checks, by querying the database, if there are some notifications to be sent, and if it is the case, sends them to the corresponding users.
You would trigger the HTTPS Cloud Function through an external service like https://cron-job.org/en/ or https://www.easycron.com/.
You will find an example of Cloud Function sending Firebase Cloud Messaging notifications in the official samples, here: https://github.com/firebase/functions-samples/tree/Node-8/fcm-notifications
In this sample, the Cloud Function is triggered by a Realtime Database event (see doc) but you can easily changed it to be triggered by an HTTP request (see doc), in order to trigger it with the cron online service.
If you are not familiar with Cloud Functions I would suggest that you watch the following official Video Series "Learning Cloud Functions for Firebase" (here in the doc), and in particular the three videos titled "Learn JavaScript Promises" which will show in details the difference between HTTPS triggered functions and Database events triggered ones.
The full doc for Cloud Functions for Firebase is here.

Related

Scheduling notification on a specific time stored in the database

I am working on a project there i need to implement notifications one day before the expiry of the documents , hour before the pickup etc. And the dates for the expiry and pickup are stored in the database I have to fetch it and send a notification to the user.
I need to implement something that could fetch the data when the expiry is near can i use firebase cloud messaging for the same? or any other ways to do it more efficiently.
Thanks in advance.
If data stored in remote database then there is two possible way.
First, all logic have to implement in remote side and server will send payload for notification, which you have to triggered through FCM.
And secondly, you can call api and implement notification on app side.
Implement a custom Firebase Cloud function that would run on a certain schedule (1h or 5 mins, based on your usecase) and would check if any documents expire within a given timeframe. If you find such documents, issue a FCM to notify the owners of the document.
It is not a good idea to implement this behavior in the app itself because nobody can guarantee that the application will be live at the time when the check should be performed. This is primarily due to android battery optimizations introduced in the latest OS versions.
For more info and examples, look at the following documentation:
Cloud Functions - https://firebase.google.com/docs/functions
Scheduled functions - https://firebase.google.com/docs/functions/schedule-functions

Firebase Cloud Message with Rest API Android

I am trying to build an app which will send notifications to the users according to the data changes from Rest API.
i.e A user subscribes that he wants to be notified when Spain scores the goal against Portugal. So my question is, is it possible to connect that link which sends requests to Rest API which I'm using to retrieve data to FCM or should I look for other product which will solve my problem?
You could do it with Cloud Functions, which "run backend code in response to events triggered by Firebase features and HTTPS requests", see the general doc here.
You could regularly trigger an HTTPS Cloud Functions that would:
Call the REST API, e.g. with Request (https://github.com/request/request)
Based on the response of the REST API, send a notification with FCM.
To send a FCM notification via Cloud Function, have a look a this official Firebase sample https://github.com/firebase/functions-samples/tree/master/fcm-notifications
To call your HTTPS Cloud Function regurlarly, you have to trigger it via http through a cron-job.
Have a look at: https://firebase.google.com/docs/functions/http-events and
https://www.youtube.com/watch?v=CbE2PzvAMxA. You could also use another online CRON service to call the HTTPS Function, like https://www.easycron.com/
Note that you would need to be on Blaze Plan to be able to query an outside service.

Notify my users automatically using firebase

I designed movie program that let user to select specific movies to let him follow any new news about it. For any important article i notify my user using firebase notification but how to make it automation to notify any one of them about any specific movie or category ?
according to my googling i can do that using google app engine but i am not sure !
There are multiple routes to go about what you are looking for. All of them will require you to set up a server, either on app engine or something similar, that continuously updates your database with new information. I would not rely on just data change events on your database in your app to do notifications though. I would look into Firebase Cloud Functions as well as Firebase Cloud Messaging where you wait for something in the database to change with a function, which then pushes the notifications with cloud messaging.

Firebase scheduled notification in android

I'm developing an android app using firebase, this app should push notifications twice a day by hours user should set in app settings.
I saw a similar question was asked at least 2 years ago, but no answer, maybe now there is an option to do it.
Is there anyway I can achieve this using Firebase ? If no, how can I achieve it ?
You can schedule sending notifications from the Firebase console. But that is limited to notifications you manually enter. There is no way to schedule "twice a day" delivery, nor is there an API to schedule the delivery programmatically.
This means that you'll have to write code to implement this yourself. One way to do this would be to use the Firebase Cloud Messaging API to send the messages, use the Firebase Realtime Database (or Cloud Firestore) to store information on when and where to send the messages, and then invoke a Cloud Function on a schedule to read the information from the database and call the FCM API.

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