Created
May 9, 2020 21:05
-
-
Save shreyakupadhyay/e4074c3dcd5067fb71d71f843ac0c6df to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Push Notifications constants | |
let baseNotification = new firebase.notifications.Notification({ | |
sound: 'default', | |
show_in_foreground: true, | |
}) | |
.setSound("default") | |
.android.setChannelId('channelId') // id you have set in HandleNotifications.js | |
.android.setColor('#ffffff') // you can set a color here | |
.android.setPriority(firebase.notifications.Android.Priority.High) | |
.android.setSmallIcon('ic_launcher') | |
.android.setAutoCancel(true); | |
// notification actions | |
const takenAction = new firebase.notifications.Android.Action('medicine_taken', 'default', 'Taken'); | |
const snoozAction = new firebase.notifications.Android.Action('snooz', 'default', '30 min Later'); | |
// creating notification | |
const bigText = "Please take Medicine on time. Have you already taken it?"; | |
baseNotification | |
.setNotificationId('reminder') | |
.setTitle('Reminder') | |
.setBody(bigText) | |
.setData({medicineId: '2'}) | |
.android.addAction(takenAction) // adding | |
.android.addAction(snoozAction); // snoozing | |
const schedule = { | |
fireDate: new Date().getTime(), | |
}; | |
// scheduling notifications | |
firebase.notifications().scheduleNotification(baseNotification, schedule); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment