Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cordova-plugin-local-notifications
Overview
Overview
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
Nabil Sadki
cordova-plugin-local-notifications
Commits
44a0da5c
Commit
44a0da5c
authored
Aug 24, 2017
by
Sebastián Katzer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace every/at with new trigger property
parent
b7773573
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
26 deletions
+55
-26
local-notification-util.js
www/local-notification-util.js
+55
-26
No files found.
www/local-notification-util.js
View file @
44a0da5c
...
@@ -28,11 +28,9 @@ exports._defaults = {
...
@@ -28,11 +28,9 @@ exports._defaults = {
text
:
''
,
text
:
''
,
title
:
''
,
title
:
''
,
sound
:
'res://platform_default'
,
sound
:
'res://platform_default'
,
trigger
:
'date'
,
badge
:
undefined
,
badge
:
undefined
,
data
:
undefined
,
data
:
undefined
,
every
:
undefined
,
trigger
:
{
type
:
'calendar'
},
at
:
undefined
,
actions
:
[],
actions
:
[],
actionGroupId
:
undefined
,
actionGroupId
:
undefined
,
attachments
:
[]
attachments
:
[]
...
@@ -58,12 +56,6 @@ exports.applyPlatformSpecificOptions = function () {
...
@@ -58,12 +56,6 @@ exports.applyPlatformSpecificOptions = function () {
defaults
.
led
=
undefined
;
defaults
.
led
=
undefined
;
defaults
.
color
=
undefined
;
defaults
.
color
=
undefined
;
break
;
break
;
case
'iOS'
:
defaults
.
region
=
undefined
;
defaults
.
radius
=
undefined
;
defaults
.
notifyOnEntry
=
true
;
defaults
.
notifyOnExit
=
false
;
break
;
}
}
};
};
...
@@ -77,7 +69,6 @@ exports.applyPlatformSpecificOptions = function () {
...
@@ -77,7 +69,6 @@ exports.applyPlatformSpecificOptions = function () {
exports
.
mergeWithDefaults
=
function
(
options
)
{
exports
.
mergeWithDefaults
=
function
(
options
)
{
var
defaults
=
this
.
getDefaults
();
var
defaults
=
this
.
getDefaults
();
options
.
at
=
this
.
getValueFor
(
options
,
'at'
,
'firstAt'
,
'date'
);
options
.
text
=
this
.
getValueFor
(
options
,
'text'
,
'message'
);
options
.
text
=
this
.
getValueFor
(
options
,
'text'
,
'message'
);
options
.
data
=
this
.
getValueFor
(
options
,
'data'
,
'json'
);
options
.
data
=
this
.
getValueFor
(
options
,
'data'
,
'json'
);
...
@@ -89,10 +80,6 @@ exports.mergeWithDefaults = function (options) {
...
@@ -89,10 +80,6 @@ exports.mergeWithDefaults = function (options) {
options
.
autoClear
=
false
;
options
.
autoClear
=
false
;
}
}
if
(
options
.
at
===
undefined
||
options
.
at
===
null
)
{
options
.
at
=
new
Date
();
}
for
(
var
key
in
defaults
)
{
for
(
var
key
in
defaults
)
{
if
(
options
[
key
]
===
null
||
options
[
key
]
===
undefined
)
{
if
(
options
[
key
]
===
null
||
options
[
key
]
===
undefined
)
{
if
(
options
.
hasOwnProperty
(
key
)
&&
[
'data'
,
'sound'
].
indexOf
(
key
)
>
-
1
)
{
if
(
options
.
hasOwnProperty
(
key
)
&&
[
'data'
,
'sound'
].
indexOf
(
key
)
>
-
1
)
{
...
@@ -105,7 +92,7 @@ exports.mergeWithDefaults = function (options) {
...
@@ -105,7 +92,7 @@ exports.mergeWithDefaults = function (options) {
for
(
key
in
options
)
{
for
(
key
in
options
)
{
if
(
!
defaults
.
hasOwnProperty
(
key
))
{
if
(
!
defaults
.
hasOwnProperty
(
key
))
{
delete
options
[
key
];
//
delete options[key];
console
.
warn
(
'Unknown property: '
+
key
);
console
.
warn
(
'Unknown property: '
+
key
);
}
}
}
}
...
@@ -148,21 +135,12 @@ exports.convertProperties = function (options) {
...
@@ -148,21 +135,12 @@ exports.convertProperties = function (options) {
}
}
}
}
if
(
options
.
at
)
{
if
(
typeof
options
.
at
==
'object'
)
{
options
.
at
=
options
.
at
.
getTime
();
}
options
.
at
=
Math
.
round
(
options
.
at
/
1000
);
}
if
(
typeof
options
.
data
==
'object'
)
{
if
(
typeof
options
.
data
==
'object'
)
{
options
.
data
=
JSON
.
stringify
(
options
.
data
);
options
.
data
=
JSON
.
stringify
(
options
.
data
);
}
}
if
(
options
.
actions
)
{
this
.
convertTrigger
(
options
);
this
.
convertActions
(
options
);
this
.
convertActions
(
options
);
}
return
options
;
return
options
;
};
};
...
@@ -198,6 +176,57 @@ exports.convertActions = function (options) {
...
@@ -198,6 +176,57 @@ exports.convertActions = function (options) {
options
.
category
=
(
options
.
category
||
'DEFAULT_GROUP'
).
toString
();
options
.
category
=
(
options
.
category
||
'DEFAULT_GROUP'
).
toString
();
options
.
actions
=
actions
;
options
.
actions
=
actions
;
return
options
;
};
/**
* Convert the passed values for the trigger to their required type.
*
* @param [ Map ] options Set of custom values.
*
* @return [ Map ] Interaction object with trigger spec.
*/
exports
.
convertTrigger
=
function
(
options
)
{
var
cfg
=
options
.
trigger
,
isDate
=
Date
.
prototype
.
isPrototypeOf
(
cfg
),
isObject
=
Object
.
prototype
.
isPrototypeOf
(
cfg
),
trigger
=
!
isDate
&&
isObject
?
cfg
:
{},
date
=
this
.
getValueFor
(
trigger
,
'at'
,
'firstAt'
,
'date'
);
if
(
!
trigger
.
type
)
{
trigger
.
type
=
trigger
.
center
?
'location'
:
'calendar'
;
}
var
isCal
=
trigger
.
type
==
'calendar'
;
if
(
isCal
&&
!
date
)
{
date
=
this
.
getValueFor
(
options
,
'at'
,
'firstAt'
,
'date'
)
||
new
Date
();
}
if
(
isCal
)
{
date
=
typeof
date
==
'object'
?
date
.
getTime
()
:
date
;
trigger
.
at
=
Math
.
round
(
date
/
1000
);
}
if
(
isCal
&&
!
trigger
.
every
&&
options
.
every
)
{
trigger
.
every
=
options
.
every
;
}
if
(
!
isCal
)
{
trigger
.
notifyOnEntry
=
!!
trigger
.
notifyOnEntry
;
trigger
.
notifyOnExit
=
trigger
.
notifyOnExit
===
true
;
trigger
.
radius
=
trigger
.
radius
||
5
;
}
delete
options
.
every
;
delete
options
.
at
;
delete
options
.
firstAt
;
delete
options
.
date
;
options
.
trigger
=
trigger
;
return
options
;
};
};
/**
/**
...
...
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