So i am using Firebase for my project. And what is does is that every time a new record is added into a specific collection in Firestore, my Firebase Function will be triggered thus sending the push notification into the devices of users who are subscribe to a specific topic.
Here is the code that i used for Firebase Function:
exports.sendNotifications = functions.firestore
.document('notifications/{sessionId}').onCreate(async event => {
const newValue = event.data();
// Gets data from the new notification record in Firestore.
const topicId = newValue.topicId;
const themeId = newValue.themeId;
const colorId = newValue.colorId;
let lable = newValue.lable;
let header = newValue.header;
// Limit the number of characters for push notifications
if(header.length >= 50){
header = header.substring(0,47) + "...";
} if(lable.length >= 100){
lable = lable.substring(0,97) + "...";
}
// Set the message for the notification.
const payload = {
notification: {
title: header,
body: lable,
}
}
let options = {
priority: 'high'
};
// Sends the notification to the users subscribed to the said topic
return admin.messaging().sendToTopic(topicId, payload, options)
});
Since the Function triggers and sends push notifications to all my users subscribe to a topic at the same time. Is it possible for the device (the receiving end) to not show the notification sent by my Function up until a specific time comes?
Cause users of my Ionic app needs to choose what time of the day they will be receiving push notification from the cloud.
I am aware that in the Firebase console, you can send notifications manually using a form and set the time and date in where the notification will be sent, but this does not work on my favor since my users did not set the same time and date for notifications to be showing.