Commit fa48038f authored by Phuengton Chummuel's avatar Phuengton Chummuel

create utils file for easy use

parent 910ad24e
import PushNotification from 'react-native-push-notification';
import moment from 'moment'
export function formatDate(date) {
var monthNames = [
"January", "February", "March",
"April", "May", "June", "July",
"August", "September", "October",
"November", "December"
];
var day = date.getDate();
var monthIndex = date.getMonth();
return 'Today, ' + day + ' ' + monthNames[monthIndex];
}
export function scheduleLocalNotification(message, date, id, payload) {
//message: type String
//date: type String format 'YYYY-MM-DD HH:mm' (NOTIFICATION_DATE_TIME_FORMAT)
//construct the notification parameters
// const fireDate = moment(date, NOTIFICATION_DATE_TIME_FORMAT).toDate();
const fireDate = date
const notification = {
id: id, //for android cancel notification (must be stringified number)
message,
number: 0, //necessary for iOS cancellation (not sure why)
date: fireDate,
//for android only
data: JSON.stringify(payload),
};
//schedule the notification
PushNotification.localNotificationSchedule(notification);
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment