Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
pill_minder
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Phuengton Chummuel
pill_minder
Commits
fa48038f
Commit
fa48038f
authored
Feb 06, 2018
by
Phuengton Chummuel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
create utils file for easy use
parent
910ad24e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
0 deletions
+37
-0
Utils.js
src/Utils.js
+37
-0
No files found.
src/Utils.js
0 → 100644
View file @
fa48038f
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment