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
320e32f4
Commit
320e32f4
authored
Oct 01, 2017
by
Sebastián Katzer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not schedule notifications old then 1 minute (Windows)
parent
404db4f3
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
60 additions
and
16 deletions
+60
-16
Builder.cs
...Proxy/LocalNotificationProxy/LocalNotification/Builder.cs
+15
-1
Every.cs
...onProxy/LocalNotificationProxy/LocalNotification/Every.cs
+3
-3
Manager.cs
...Proxy/LocalNotificationProxy/LocalNotification/Manager.cs
+8
-3
Notification.cs
.../LocalNotificationProxy/LocalNotification/Notification.cs
+1
-1
Trigger.cs
...Proxy/LocalNotificationProxy/LocalNotification/Trigger.cs
+33
-8
No files found.
src/windows/LocalNotificationProxy/LocalNotificationProxy/LocalNotification/Builder.cs
View file @
320e32f4
...
...
@@ -168,7 +168,21 @@ namespace LocalNotificationProxy.LocalNotification
{
var
xml
=
toast
.
GetXml
();
var
at
=
this
.
Content
.
Date
;
var
notification
=
new
ScheduledToastNotification
(
xml
,
at
);
ScheduledToastNotification
notification
;
if
(!
at
.
HasValue
)
{
return
null
;
}
try
{
notification
=
new
ScheduledToastNotification
(
xml
,
at
.
Value
);
}
catch
{
return
null
;
}
notification
.
Id
=
this
.
Content
.
Id
;
notification
.
Tag
=
this
.
Options
.
Id
.
ToString
();
...
...
src/windows/LocalNotificationProxy/LocalNotificationProxy/LocalNotification/Every.cs
View file @
320e32f4
...
...
@@ -92,9 +92,9 @@ namespace LocalNotificationProxy.LocalNotification
var
p
=
this
.
ToArray
();
var
today
=
DateTime
.
Today
;
p
[
2
]
=
this
.
Day
>
0
?
this
.
Day
:
today
.
Day
;
p
[
3
]
=
this
.
Month
>
0
?
this
.
Month
:
today
.
Month
;
p
[
4
]
=
this
.
Year
>
0
?
this
.
Year
:
today
.
Year
;
p
[
2
]
=
this
.
Day
IsVariable
?
today
.
Day
:
this
.
Day
;
p
[
3
]
=
this
.
Month
IsVariable
?
today
.
Month
:
this
.
Month
;
p
[
4
]
=
this
.
Year
IsVariable
?
today
.
Year
:
this
.
Year
;
return
new
DateTime
(
p
[
4
],
p
[
3
],
p
[
2
],
p
[
1
],
p
[
0
],
0
);
}
...
...
src/windows/LocalNotificationProxy/LocalNotificationProxy/LocalNotification/Manager.cs
View file @
320e32f4
...
...
@@ -47,14 +47,19 @@ namespace LocalNotificationProxy.LocalNotification
foreach
(
Options
options
in
notifications
)
{
var
builder
=
new
Builder
(
options
);
ScheduledToastNotification
toast
;
do
{
toast
=
builder
.
Build
();
var
toast
=
builder
.
Build
();
if
(
toast
!=
null
)
{
ToastNotifier
.
AddToSchedule
(
toast
);
}
builder
.
MoveNext
();
}
while
(
builder
.
HasNext
());
}
while
(
builder
.
HasNext
());
}
}
...
...
src/windows/LocalNotificationProxy/LocalNotificationProxy/LocalNotification/Notification.cs
View file @
320e32f4
...
...
@@ -288,7 +288,7 @@
/// <summary>
/// Gets the date when to trigger the notification.
/// </summary>
public
DateTime
Date
public
DateTime
?
Date
{
get
{
...
...
src/windows/LocalNotificationProxy/LocalNotificationProxy/LocalNotification/Trigger.cs
View file @
320e32f4
...
...
@@ -61,7 +61,7 @@ namespace LocalNotificationProxy.LocalNotification
/// <summary>
/// Gets the date when to trigger the notification.
/// </summary>
internal
DateTime
Date
internal
DateTime
?
Date
{
get
{
...
...
@@ -70,10 +70,30 @@ namespace LocalNotificationProxy.LocalNotification
this
.
triggerDate
=
this
.
Every
is
Every
?
this
.
GetRelDate
()
:
this
.
GetFixDate
();
}
if
(!
this
.
triggerDate
.
HasValue
)
{
return
null
;
}
var
date
=
this
.
GetNextTriggerDate
();
var
minDate
=
DateTime
.
Now
.
AddSeconds
(
0.
1
);
var
minDate
=
DateTime
.
Now
.
AddSeconds
(
0.
2
);
return
(
date
<
minDate
)
?
minDate
:
date
;
if
(!
date
.
HasValue
)
{
return
null
;
}
if
(
date
>=
minDate
)
{
return
date
;
}
if
((
minDate
-
date
).
Value
.
TotalMinutes
<=
1
)
{
return
minDate
;
}
return
null
;
}
}
...
...
@@ -148,17 +168,22 @@ namespace LocalNotificationProxy.LocalNotification
/// Gets the date when to trigger the notification.
/// </summary>
/// <returns>The first matching date specified by trigger.every</returns>
private
DateTime
GetRelDate
()
private
DateTime
?
GetRelDate
()
{
var
every
=
this
.
Every
as
Every
;
var
date
=
every
.
ToDateTime
();
var
now
=
DateTime
.
Now
;
if
(
date
>=
now
||
date
.
Year
<
now
.
Year
)
if
(
date
>=
now
)
{
return
date
;
}
if
(
date
.
Year
<
now
.
Year
)
{
return
null
;
}
if
(
date
.
Month
<
now
.
Month
)
{
switch
(
every
.
Interval
)
...
...
@@ -240,14 +265,14 @@ namespace LocalNotificationProxy.LocalNotification
}
}
return
date
;
return
null
;
}
/// <summary>
/// Calculates the next trigger date by adding (interval * occurence)
/// </summary>
/// <returns>The next valid trigger date</returns>
private
DateTime
GetNextTriggerDate
()
private
DateTime
?
GetNextTriggerDate
()
{
var
every
=
this
.
Every
is
Every
?
(
this
.
Every
as
Every
).
Interval
:
this
.
Every
;
var
date
=
this
.
triggerDate
.
Value
;
...
...
@@ -285,7 +310,7 @@ namespace LocalNotificationProxy.LocalNotification
}
catch
{
return
date
;
return
null
;
}
}
}
...
...
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