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
cb831ad8
Commit
cb831ad8
authored
Jan 11, 2018
by
Sebastián Katzer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented trigger: before for Android and Windows
parent
fb993c31
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
16 deletions
+47
-16
README.md
README.md
+2
-2
Request.java
src/android/notification/Request.java
+12
-8
Request.cs
...Proxy/LocalNotificationProxy/LocalNotification/Request.cs
+23
-3
Trigger.cs
...LocalNotificationProxy/LocalNotification/Toast/Trigger.cs
+10
-3
No files found.
README.md
View file @
cb831ad8
...
...
@@ -285,7 +285,7 @@ The properties depend on the trigger type. Not all of them are supported across
| | every | String |
`month`
| x | x | x |
| | every | String |
`quarter`
| x | | x |
| | every | String |
`year`
| x | x | x |
| | before | Date | |
| | before | Date | |
x | | x |
| | firstAt | Date | | x | x | x |
| Match |
| | count | Int | | x | | x |
...
...
@@ -299,7 +299,7 @@ The properties depend on the trigger type. Not all of them are supported across
| | every | Object |
`month`
| x | x | x |
| | every | Object |
`quarter`
| | x |
| | every | Object |
`year`
| x | x | x |
| | before | Date | |
| | before | Date | |
x | | x |
| | after | Date | | x | x | x |
| Location |
| | center | Array |
`[lat, long]`
| | x |
...
...
src/android/notification/Request.java
View file @
cb831ad8
...
...
@@ -88,7 +88,7 @@ public final class Request {
*
* @return The notification ID as the string
*/
public
String
getIdentifier
()
{
String
getIdentifier
()
{
return
options
.
getId
().
toString
()
+
"-"
+
getOccurrence
();
}
...
...
@@ -130,9 +130,13 @@ public final class Request {
if
(
triggerDate
==
null
)
return
null
;
if
((
now
.
getTimeInMillis
()
-
triggerDate
.
getTime
())
>
60000
)
{
long
time
=
triggerDate
.
getTime
();
if
((
now
.
getTimeInMillis
()
-
time
)
>
60000
)
return
null
;
if
(
time
>=
spec
.
optLong
(
"before"
,
time
+
1
))
return
null
;
}
return
triggerDate
;
}
...
...
@@ -151,8 +155,8 @@ public final class Request {
Object
every
=
spec
.
opt
(
"every"
);
if
(
every
instanceof
JSONObject
)
{
List
<
Integer
>
cmp1
=
getMatch
er
s
();
List
<
Integer
>
cmp2
=
getSpecials
();
List
<
Integer
>
cmp1
=
getMatch
ingComponent
s
();
List
<
Integer
>
cmp2
=
getSpecial
MatchingComponent
s
();
return
new
MatchTrigger
(
cmp1
,
cmp2
);
}
...
...
@@ -208,7 +212,7 @@ public final class Request {
*
* @return [min, hour, day, month, year]
*/
private
List
<
Integer
>
getMatch
er
s
()
{
private
List
<
Integer
>
getMatch
ingComponent
s
()
{
JSONObject
every
=
spec
.
optJSONObject
(
"every"
);
return
Arrays
.
asList
(
...
...
@@ -223,9 +227,9 @@ public final class Request {
/**
* Gets an array of all date parts to construct a datetime instance.
*
* @return [
weekday, weekdayOrdinal, weekOfMonth, quarte
r]
* @return [
min, hour, day, month, yea
r]
*/
private
List
<
Integer
>
getSpecials
()
{
private
List
<
Integer
>
getSpecial
MatchingComponent
s
()
{
JSONObject
every
=
spec
.
optJSONObject
(
"every"
);
return
Arrays
.
asList
(
...
...
src/windows/LocalNotificationProxy/LocalNotificationProxy/LocalNotification/Request.cs
View file @
cb831ad8
...
...
@@ -85,6 +85,16 @@ namespace LocalNotificationProxy.LocalNotification
return
null
;
}
if
(
this
.
spec
.
Before
!=
0
)
{
var
before
=
this
.
ToDateTime
(
this
.
spec
.
Before
);
if
(
this
.
triggerDate
.
Value
>=
before
)
{
return
null
;
}
}
var
minDate
=
DateTime
.
Now
.
AddSeconds
(
0.2
);
if
(
this
.
triggerDate
>=
minDate
)
...
...
@@ -238,18 +248,28 @@ namespace LocalNotificationProxy.LocalNotification
{
if
(
this
.
spec
.
At
!=
0
)
{
return
DateTimeOffset
.
FromUnixTimeMilliseconds
(
this
.
spec
.
At
).
LocalDateTime
;
return
this
.
ToDateTime
(
this
.
spec
.
At
)
;
}
else
if
(
this
.
spec
.
FirstAt
!=
0
)
{
return
DateTimeOffset
.
FromUnixTimeMilliseconds
(
this
.
spec
.
FirstAt
).
LocalDateTime
;
return
this
.
ToDateTime
(
this
.
spec
.
FirstAt
)
;
}
else
if
(
this
.
spec
.
After
!=
0
)
{
return
DateTimeOffset
.
FromUnixTimeMilliseconds
(
this
.
spec
.
After
).
LocalDateTime
;
return
this
.
ToDateTime
(
this
.
spec
.
After
)
;
}
return
DateTime
.
Now
;
}
/// <summary>
/// Unix time from milliseconds.
/// </summary>
/// <param name="ms">Milliseconds </param>
/// <returns>DateTime object.</returns>
private
DateTime
ToDateTime
(
long
ms
)
{
return
DateTimeOffset
.
FromUnixTimeMilliseconds
(
ms
).
LocalDateTime
;
}
}
}
src/windows/LocalNotificationProxy/LocalNotificationProxy/LocalNotification/Toast/Trigger.cs
View file @
cb831ad8
...
...
@@ -43,6 +43,11 @@ namespace LocalNotificationProxy.LocalNotification.Toast
public
long
FirstAt
{
get
;
set
;
}
=
0
;
/// <summary>
/// Gets or sets the before trigger date.
/// </summary>
public
long
Before
{
get
;
set
;
}
=
0
;
/// <summary>
/// Gets or sets the after trigger date.
/// </summary>
public
long
After
{
get
;
set
;
}
=
0
;
...
...
@@ -85,9 +90,10 @@ namespace LocalNotificationProxy.LocalNotification.Toast
var
trigger
=
new
Trigger
();
var
node
=
doc
.
DocumentElement
;
trigger
.
At
=
int
.
Parse
(
node
.
GetAttribute
(
"at"
));
trigger
.
FirstAt
=
int
.
Parse
(
node
.
GetAttribute
(
"firstAt"
));
trigger
.
After
=
int
.
Parse
(
node
.
GetAttribute
(
"after"
));
trigger
.
At
=
long
.
Parse
(
node
.
GetAttribute
(
"at"
));
trigger
.
FirstAt
=
long
.
Parse
(
node
.
GetAttribute
(
"firstAt"
));
trigger
.
Before
=
long
.
Parse
(
node
.
GetAttribute
(
"before"
));
trigger
.
After
=
long
.
Parse
(
node
.
GetAttribute
(
"after"
));
trigger
.
In
=
int
.
Parse
(
node
.
GetAttribute
(
"in"
));
trigger
.
Count
=
int
.
Parse
(
node
.
GetAttribute
(
"count"
));
trigger
.
Occurrence
=
int
.
Parse
(
node
.
GetAttribute
(
"occurrence"
));
...
...
@@ -119,6 +125,7 @@ namespace LocalNotificationProxy.LocalNotification.Toast
node
.
SetAttribute
(
"at"
,
this
.
At
.
ToString
());
node
.
SetAttribute
(
"firstAt"
,
this
.
FirstAt
.
ToString
());
node
.
SetAttribute
(
"before"
,
this
.
Before
.
ToString
());
node
.
SetAttribute
(
"after"
,
this
.
After
.
ToString
());
node
.
SetAttribute
(
"in"
,
this
.
In
.
ToString
());
node
.
SetAttribute
(
"count"
,
this
.
Count
.
ToString
());
...
...
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