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
f3f4e4d5
Commit
f3f4e4d5
authored
Aug 17, 2017
by
Sebastián Katzer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented clear, clearAll, cancel and cancelAll for Windows
parent
b69640e0
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
164 additions
and
0 deletions
+164
-0
LocalNotificationProxy.js
src/windows/LocalNotificationProxy.js
+38
-0
Manager.cs
...Proxy/LocalNotificationProxy/LocalNotification/Manager.cs
+90
-0
LocalNotificationProxy.cs
...ionProxy/LocalNotificationProxy/LocalNotificationProxy.cs
+36
-0
No files found.
src/windows/LocalNotificationProxy.js
View file @
f3f4e4d5
...
@@ -102,6 +102,25 @@ exports.schedule = function (success, error, args) {
...
@@ -102,6 +102,25 @@ exports.schedule = function (success, error, args) {
};
};
/**
/**
* Clear the notifications specified by id.
*
* @param [ Function ] success Success callback
* @param [ Function ] error Error callback
* @param [ Array ] args Interface arguments
*
* @return [ Void ]
*/
exports
.
clear
=
function
(
success
,
error
,
args
)
{
var
toasts
=
impl
.
clear
(
args
)
||
[];
for
(
var
i
=
0
;
i
<
toasts
.
length
;
i
++
)
{
exports
.
fireEvent
(
'clear'
,
toasts
[
i
]);
}
success
();
};
/**
* Clear all notifications.
* Clear all notifications.
*
*
* @param [ Function ] success Success callback
* @param [ Function ] success Success callback
...
@@ -116,6 +135,25 @@ exports.clearAll = function (success, error) {
...
@@ -116,6 +135,25 @@ exports.clearAll = function (success, error) {
};
};
/**
/**
* Cancel the notifications specified by id.
*
* @param [ Function ] success Success callback
* @param [ Function ] error Error callback
* @param [ Array ] args Interface arguments
*
* @return [ Void ]
*/
exports
.
cancel
=
function
(
success
,
error
,
args
)
{
var
toasts
=
impl
.
cancel
(
args
)
||
[];
for
(
var
i
=
0
;
i
<
toasts
.
length
;
i
++
)
{
exports
.
fireEvent
(
'cancel'
,
toasts
[
i
]);
}
success
();
};
/**
* Cancel all notifications.
* Cancel all notifications.
*
*
* @param [ Function ] success Success callback
* @param [ Function ] success Success callback
...
...
src/windows/LocalNotificationProxy/LocalNotificationProxy/LocalNotification/Manager.cs
View file @
f3f4e4d5
...
@@ -52,6 +52,96 @@ namespace LocalNotificationProxy.LocalNotification
...
@@ -52,6 +52,96 @@ namespace LocalNotificationProxy.LocalNotification
}
}
/// <summary>
/// <summary>
/// Clear the notifications specified by id.
/// </summary>
/// <param name="ids">The IDs of the notification to clear.</param>
/// <returns>The cleared notifications.</returns>
public
List
<
Options
>
Clear
(
int
[]
ids
)
{
var
triggered
=
ToastNotificationManager
.
History
.
GetHistory
();
var
tags
=
new
List
<
int
>(
ids
);
var
toasts
=
new
List
<
Options
>();
foreach
(
var
toast
in
triggered
)
{
var
id
=
int
.
Parse
(
toast
.
Tag
);
if
(
tags
.
Contains
(
id
))
{
tags
.
Remove
(
id
);
toasts
.
Add
(
new
Notification
(
toast
).
Options
);
ToastNotificationManager
.
History
.
Remove
(
toast
.
Tag
);
}
if
(
tags
.
Count
==
0
)
{
break
;
}
}
return
toasts
;
}
/// <summary>
/// Clear all notifications.
/// </summary>
public
void
ClearAll
()
{
ToastNotificationManager
.
History
.
Clear
();
}
/// <summary>
/// Cancel the notifications specified by id.
/// </summary>
/// <param name="ids">The IDs of the notification to clear.</param>
/// <returns>The cleared notifications.</returns>
public
List
<
Options
>
Cancel
(
int
[]
ids
)
{
var
scheduled
=
ToastNotifier
.
GetScheduledToastNotifications
();
var
tags
=
new
List
<
int
>(
ids
);
var
toasts
=
new
List
<
Options
>();
foreach
(
var
toast
in
scheduled
)
{
var
id
=
int
.
Parse
(
toast
.
Tag
);
if
(
tags
.
Contains
(
id
))
{
tags
.
Remove
(
id
);
toasts
.
Add
(
new
Notification
(
toast
).
Options
);
ToastNotifier
.
RemoveFromSchedule
(
toast
);
}
if
(
tags
.
Count
==
0
)
{
break
;
}
}
if
(
tags
.
Count
>
0
)
{
toasts
.
AddRange
(
this
.
Clear
(
tags
.
ToArray
()));
}
return
toasts
;
}
/// <summary>
/// Cancel all notifications.
/// </summary>
public
void
CancelAll
()
{
var
toasts
=
ToastNotifier
.
GetScheduledToastNotifications
();
foreach
(
var
toast
in
toasts
)
{
ToastNotifier
.
RemoveFromSchedule
(
toast
);
}
this
.
ClearAll
();
}
/// <summary>
/// Gets all notifications by id.
/// Gets all notifications by id.
/// </summary>
/// </summary>
/// <returns>List of ids</returns>
/// <returns>List of ids</returns>
...
...
src/windows/LocalNotificationProxy/LocalNotificationProxy/LocalNotificationProxy.cs
View file @
f3f4e4d5
...
@@ -50,6 +50,42 @@ namespace LocalNotificationProxy
...
@@ -50,6 +50,42 @@ namespace LocalNotificationProxy
}
}
/// <summary>
/// <summary>
/// Clear the notifications specified by id.
/// </summary>
/// <param name="ids">The IDs of the notification to clear.</param>
/// <returns>The cleared notifications.</returns>
public
Options
[]
Clear
([
ReadOnlyArray
]
int
[]
ids
)
{
return
this
.
manager
.
Clear
(
ids
).
ToArray
();
}
/// <summary>
/// Clear all notifications.
/// </summary>
public
void
ClearAll
()
{
this
.
manager
.
ClearAll
();
}
/// <summary>
/// Cancel the notifications specified by id.
/// </summary>
/// <param name="ids">The IDs of the notification to clear.</param>
/// <returns>The cleared notifications.</returns>
public
Options
[]
Cancel
([
ReadOnlyArray
]
int
[]
ids
)
{
return
this
.
manager
.
Cancel
(
ids
).
ToArray
();
}
/// <summary>
/// Cancel all notifications.
/// </summary>
public
void
CancelAll
()
{
this
.
manager
.
CancelAll
();
}
/// <summary>
/// Gets the type of the notification specified by ID.
/// Gets the type of the notification specified by ID.
/// </summary>
/// </summary>
/// <param name="id">The ID of the notification to find for.</param>
/// <param name="id">The ID of the notification to find for.</param>
...
...
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