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
0224f67c
Commit
0224f67c
authored
Aug 16, 2017
by
Sebastián Katzer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added query methods to get ids and options (Windows)
parent
703d40c8
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
253 additions
and
6 deletions
+253
-6
LocalNotificationProxy.js
src/windows/LocalNotificationProxy.js
+61
-3
Manager.cs
...Proxy/LocalNotificationProxy/LocalNotification/Manager.cs
+132
-3
Notification.cs
.../LocalNotificationProxy/LocalNotification/Notification.cs
+10
-0
LocalNotificationProxy.cs
...ionProxy/LocalNotificationProxy/LocalNotificationProxy.cs
+50
-0
No files found.
src/windows/LocalNotificationProxy.js
View file @
0224f67c
...
...
@@ -108,7 +108,7 @@ exports.schedule = function (success, error, args) {
exports
.
ids
=
function
(
success
,
error
)
{
var
ids
=
impl
.
ids
()
||
[];
success
(
ids
);
success
(
Array
.
from
(
ids
)
);
};
/**
...
...
@@ -122,7 +122,7 @@ exports.ids = function (success, error) {
exports
.
scheduledIds
=
function
(
success
,
error
)
{
var
ids
=
impl
.
scheduledIds
()
||
[];
success
(
ids
);
success
(
Array
.
from
(
ids
)
);
};
/**
...
...
@@ -136,7 +136,65 @@ exports.scheduledIds = function (success, error) {
exports
.
triggeredIds
=
function
(
success
,
error
)
{
var
ids
=
impl
.
triggeredIds
()
||
[];
success
(
ids
);
success
(
Array
.
from
(
ids
));
};
/**
* Get a single notification by id.
*
* @param [ Function ] success Success callback
* @param [ Function ] error Error callback
* @param [ Array ] args Interface arguments
*
* @return [ Void ]
*/
exports
.
notification
=
function
(
success
,
error
,
args
)
{
var
obj
=
impl
.
notification
(
args
[
0
]);
success
(
obj
);
};
/**
* List of (all) notifications.
*
* @param [ Function ] success Success callback
* @param [ Function ] error Error callback
* @param [ Array ] args Interface arguments
*
* @return [ Void ]
*/
exports
.
notifications
=
function
(
success
,
error
,
args
)
{
var
objs
=
impl
.
notifications
(
args
)
||
[];
success
(
Array
.
from
(
objs
));
};
/**
* List of all scheduled notifications.
*
* @param [ Function ] success Success callback
* @param [ Function ] error Error callback
*
* @return [ Void ]
*/
exports
.
scheduledNotifications
=
function
(
success
,
error
)
{
var
objs
=
impl
.
scheduledNotifications
()
||
[];
success
(
Array
.
from
(
objs
));
};
/**
* List of all triggered notifications.
*
* @param [ Function ] success Success callback
* @param [ Function ] error Error callback
*
* @return [ Void ]
*/
exports
.
triggeredNotifications
=
function
(
success
,
error
)
{
var
objs
=
impl
.
triggeredNotifications
()
||
[];
success
(
Array
.
from
(
objs
));
};
/**
...
...
src/windows/LocalNotificationProxy/LocalNotificationProxy/LocalNotification/Manager.cs
View file @
0224f67c
...
...
@@ -93,15 +93,144 @@ namespace LocalNotificationProxy.LocalNotification
}
/// <summary>
/// Gets all notifications.
/// </summary>
/// <returns>A list of all triggered and scheduled notifications.</returns>
public
List
<
Notification
>
GetAll
()
{
return
this
.
GetByType
(
Notification
.
Type
.
All
);
}
/// <summary>
/// Gets all notifications of given type.
/// </summary>
/// <param name="type">The type of notification.</param>
/// <returns>A list of notifications.</returns>
public
List
<
Notification
>
GetByType
(
Notification
.
Type
type
)
{
var
notifications
=
new
List
<
Notification
>();
if
(
type
==
Notification
.
Type
.
All
||
type
==
Notification
.
Type
.
Scheduled
)
{
var
toasts
=
ToastNotifier
.
GetScheduledToastNotifications
();
foreach
(
var
toast
in
toasts
)
{
notifications
.
Add
(
new
Notification
(
toast
));
}
}
if
(
type
==
Notification
.
Type
.
All
||
type
==
Notification
.
Type
.
Triggered
)
{
var
toasts
=
ToastNotificationManager
.
History
.
GetHistory
();
foreach
(
var
toast
in
toasts
)
{
notifications
.
Add
(
new
Notification
(
toast
));
}
}
return
notifications
;
}
/// <summary>
/// Gets all notifications.
/// </summary>
/// <returns>A list of notification options instances.</returns>
public
List
<
Options
>
GetOptions
()
{
return
this
.
GetOptionsByType
(
Notification
.
Type
.
All
);
}
/// <summary>
/// Gets notifications specified by ID.
/// </summary>
/// <param name="ids">Optional list of IDs to find.</param>
/// <returns>A list of notification options instances.</returns>
public
List
<
Options
>
GetOptions
(
int
[]
ids
)
{
var
options
=
new
List
<
Options
>();
foreach
(
var
toast
in
this
.
Get
(
ids
))
{
options
.
Add
(
toast
.
Options
);
}
return
options
;
}
/// <summary>
/// Gets all notifications for given type.
/// </summary>
/// <param name="type">The type of notification.</param>
/// <returns>A list of notification options instances.</returns>
public
List
<
Options
>
GetOptionsByType
(
Notification
.
Type
type
)
{
var
options
=
new
List
<
Options
>();
var
toasts
=
this
.
GetByType
(
type
);
foreach
(
var
toast
in
toasts
)
{
options
.
Add
(
toast
.
Options
);
}
return
options
;
}
/// <summary>
/// Gets the notifications specified by ID.
/// </summary>
/// <param name="ids">List of IDs to find.</param>
/// <returns>List of found notifications.</returns>
public
List
<
Notification
>
Get
(
int
[]
ids
)
{
var
toasts
=
new
List
<
Notification
>();
foreach
(
var
id
in
ids
)
{
var
toast
=
this
.
Get
(
id
);
if
(
toast
!=
null
)
{
toasts
.
Add
(
toast
);
}
}
return
toasts
;
}
/// <summary>
/// Gets the notification by ID.
/// </summary>
/// <param name="id">The ID of the notification to find.</param>
/// <returns>The found instance or null.</returns>
public
Notification
Get
(
int
id
)
{
return
this
.
Get
(
id
.
ToString
());
}
/// <summary>
/// Gets the notification by ID.
/// </summary>
/// <param name="id">The ID of the notification to find.</param>
/// <returns>The found instance or null.</returns>
private
Notification
Get
(
string
id
)
public
Notification
Get
(
string
id
)
{
var
scheduled
=
ToastNotifier
.
GetScheduledToastNotifications
();
foreach
(
var
toast
in
scheduled
)
{
if
(
toast
.
Tag
==
id
)
{
foreach
(
var
toast
in
ToastNotifier
.
GetScheduledToastNotifications
())
return
new
Notification
(
toast
);
}
}
var
triggered
=
ToastNotificationManager
.
History
.
GetHistory
();
foreach
(
var
toast
in
triggered
)
{
if
(
toast
.
Id
==
id
)
if
(
toast
.
Tag
==
id
)
{
return
new
Notification
(
toast
);
}
...
...
src/windows/LocalNotificationProxy/LocalNotificationProxy/LocalNotification/Notification.cs
View file @
0224f67c
...
...
@@ -34,6 +34,16 @@
this
.
Options
=
Options
.
Parse
(
toast
.
Content
.
GetXml
());
}
/// <summary>
/// Initializes a new instance of the <see cref="Notification"/> class.
/// </summary>
/// <param name="toast">The options as a toast object.</param>
public
Notification
(
ToastNotification
toast
)
{
var
xml
=
toast
.
Content
.
DocumentElement
.
GetAttribute
(
"launch"
);
this
.
Options
=
Options
.
Parse
(
xml
);
}
public
enum
Type
{
All
,
Scheduled
,
Triggered
...
...
src/windows/LocalNotificationProxy/LocalNotificationProxy/LocalNotificationProxy.cs
View file @
0224f67c
...
...
@@ -26,6 +26,9 @@ namespace LocalNotificationProxy
public
sealed
class
LocalNotificationProxy
{
/// <summary>
/// Manager wrapps the native SDK methods.
/// </summary>
private
Manager
manager
=
new
Manager
();
/// <summary>
...
...
@@ -72,5 +75,52 @@ namespace LocalNotificationProxy
{
return
this
.
manager
.
GetIdsByType
(
Notification
.
Type
.
Triggered
).
ToArray
();
}
#pragma warning disable SA1300 // Element must begin with upper-case letter
/// <summary>
/// Gets a single notifiation specified by id.
/// </summary>
/// <param name="id">The ID of the notification to find.</param>
/// <returns>List of options instances</returns>
public
Options
notification
(
int
id
)
{
var
toast
=
this
.
manager
.
Get
(
id
);
return
toast
!=
null
?
toast
.
Options
:
null
;
}
#pragma warning restore SA1300 // Element must begin with upper-case letter
/// <summary>
/// List of (all) notifiation specified by id.
/// </summary>
/// <param name="ids">Optional list of IDs to find.</param>
/// <returns>List of options instances</returns>
public
Options
[]
Notifications
([
ReadOnlyArray
]
int
[]
ids
)
{
if
(
ids
==
null
||
ids
.
Length
==
0
)
{
return
this
.
manager
.
GetOptions
().
ToArray
();
}
return
this
.
manager
.
GetOptions
(
ids
).
ToArray
();
}
/// <summary>
/// List of all scheduled notifiation.
/// </summary>
/// <returns>List of options instances</returns>
public
Options
[]
ScheduledNotifications
()
{
return
this
.
manager
.
GetOptionsByType
(
Notification
.
Type
.
Scheduled
).
ToArray
();
}
/// <summary>
/// List of all triggered notifiation.
/// </summary>
/// <returns>List of options instances</returns>
public
Options
[]
TriggeredNotifications
()
{
return
this
.
manager
.
GetOptionsByType
(
Notification
.
Type
.
Triggered
).
ToArray
();
}
}
}
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