Firebase scheduled notification in android - 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.

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

Schedule exam date and time notification in Firebase Application

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.

How do I send user to user notifications with Firebase programmatically?

The Firebase Console allows us to send notifications to single users, groups, users subscribed to topics or to the entire user base. Is there any code that allows us to directly send notifications in the same way, but programmatically?
For example, if I had a list of users (containing their Firebase UIDs), if I click on one of the users, could I send a notification to that user through Firebase the same way the console allows us to send a notification through the console?
This Firebase Blog uses the Google App Engine Flexible Environment to actually send the notifications, but it requires a free trial and costs money.
This Quickstart doesn't really show how to send user to user notifications. It focuses on the subscription-based notifications, but this isn't really what I need.
Is there any good way of doing this with Java/Kotlin and the Firebase API?
FCM doesn't support you sending message directly from Android app to Android app. However, this is a workaround to solve your problem:
Create a firebase cloud function. Listen a special path in firebase database
Android app 1 push a data (maybe Android app 2 ID) to this path
Firebase cloud function process data, determine who to send notification (Android app 2).
Firebase cloud function push notification to Android app 2.
ref: https://firebase.google.com/docs/functions/use-cases#notify_users_when_something_interesting_happens
In a basic concept: we write our server to get action from firebase database and decision to send notification to other user by FCM. This our server can write with NodeJS or using Firebase Cloud Function (above)
Guide how to using Nodejs is here: https://firebase.googleblog.com/2016/08/sending-notifications-between-android.html

how to send notification to different different customer as per their order in android sql?

How can I send a notification from server to different user who is using my app for example if I need to send a notification to user1 about their order that your order is on your way or it will take 30 minutes to reach, how can I do that?? I think about the notification but how it is possible from the server through my app ??
I am new in android, So kindly help me.
Look into firebase cloud messaging. It used to be called Google Cloud Messaging. Its a way for your server to be able to send messages to individual users. And so long as you don't use the other services in Firebase, its free.

firebase scheduled notifications

For my app, I want users to schedule the time which they receive a specific notification. I was looking over the Firebase docs and could not find a method that would allow me to do this. Is there a way to allow users to schedule notifications with Firebase? My app is still using parse api but as of now parse notifications do not support scheduled pushes.
If plan to use the Firebase console to send messages, there's a simple option to define a time in which you you want the message to go out.
If you plan to send messages via SDK. at this time there is no setting to handle scheduling, you'll have to handle it on your server.

Categories

Resources