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
3cb3b51e
Commit
3cb3b51e
authored
Feb 20, 2018
by
Sebastián Katzer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for action groups for Windows
parent
5759483e
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
169 additions
and
97 deletions
+169
-97
LocalNotificationProxy.js
src/windows/LocalNotificationProxy.js
+41
-57
ActionGroup.cs
...y/LocalNotificationProxy/LocalNotification/ActionGroup.cs
+94
-0
Builder.cs
...Proxy/LocalNotificationProxy/LocalNotification/Builder.cs
+1
-1
LocalNotificationProxy.cs
...ionProxy/LocalNotificationProxy/LocalNotificationProxy.cs
+32
-39
LocalNotificationProxy.csproj
...roxy/LocalNotificationProxy/LocalNotificationProxy.csproj
+1
-0
LocalNotificationProxy.winmd
src/windows/lib.UW/ARM/LocalNotificationProxy.winmd
+0
-0
LocalNotificationProxy.winmd
src/windows/lib.UW/x64/LocalNotificationProxy.winmd
+0
-0
LocalNotificationProxy.winmd
src/windows/lib.UW/x86/LocalNotificationProxy.winmd
+0
-0
No files found.
src/windows/LocalNotificationProxy.js
View file @
3cb3b51e
...
...
@@ -68,7 +68,6 @@ exports.ready = function () {
*/
exports
.
check
=
function
(
success
,
error
)
{
var
granted
=
impl
.
hasPermission
();
success
(
granted
);
};
...
...
@@ -213,7 +212,6 @@ exports.cancelAll = function (success, error) {
*/
exports
.
type
=
function
(
success
,
error
,
args
)
{
var
type
=
impl
.
type
(
args
[
0
]);
success
(
type
);
};
...
...
@@ -222,40 +220,12 @@ exports.type = function (success, error, args) {
*
* @param [ Function ] success Success callback
* @param [ Function ] error Error callback
* @param [ Array ] args Interface arguments
*
* @return [ Void ]
*/
exports
.
ids
=
function
(
success
,
error
)
{
var
ids
=
impl
.
ids
()
||
[];
success
(
Array
.
from
(
ids
));
};
/**
* List of all scheduled notification ids.
*
* @param [ Function ] success Success callback
* @param [ Function ] error Error callback
*
* @return [ Void ]
*/
exports
.
scheduledIds
=
function
(
success
,
error
)
{
var
ids
=
impl
.
scheduledIds
()
||
[];
success
(
Array
.
from
(
ids
));
};
/**
* List of all triggered notification ids.
*
* @param [ Function ] success Success callback
* @param [ Function ] error Error callback
*
* @return [ Void ]
*/
exports
.
triggeredIds
=
function
(
success
,
error
)
{
var
ids
=
impl
.
triggeredIds
()
||
[];
exports
.
ids
=
function
(
success
,
error
,
args
)
{
var
ids
=
impl
.
ids
(
args
[
0
])
||
[];
success
(
Array
.
from
(
ids
));
};
...
...
@@ -270,7 +240,6 @@ exports.triggeredIds = function (success, error) {
*/
exports
.
notification
=
function
(
success
,
error
,
args
)
{
var
obj
=
impl
.
notification
(
args
[
0
]);
success
(
exports
.
clone
(
obj
));
};
...
...
@@ -284,37 +253,42 @@ exports.notification = function (success, error, args) {
* @return [ Void ]
*/
exports
.
notifications
=
function
(
success
,
error
,
args
)
{
var
objs
=
impl
.
notifications
(
args
)
||
[];
var
objs
=
impl
.
notifications
(
args
[
0
],
args
[
1
])
||
[];
success
(
exports
.
cloneAll
(
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
(
exports
.
cloneAll
(
objs
));
};
/**
* List of all triggered notifications.
* Manage action groups.
*
* @param [ Function ] success Success callback
* @param [ Function ] error Error callback
* @param [ Array ] args Interface arguments
*
* @return [ Void ]
*/
exports
.
triggeredNotifications
=
function
(
success
,
error
)
{
var
objs
=
impl
.
triggeredNotifications
()
||
[];
exports
.
actions
=
function
(
success
,
error
,
args
)
{
var
ActionGroup
=
LocalNotification
.
ActionGroup
,
code
=
args
[
0
],
id
=
args
[
1
],
res
=
[],
opts
,
group
;
switch
(
code
)
{
case
0
:
opts
=
exports
.
parseOptions
(
args
[
2
]);
group
=
new
ActionGroup
(
id
,
opts
.
actions
);
ActionGroup
.
register
(
group
);
break
;
case
1
:
ActionGroup
.
unregister
(
id
);
break
;
case
2
:
res
.
push
(
ActionGroup
.
isRegistered
(
id
));
break
;
}
success
(
exports
.
cloneAll
(
objs
)
);
success
.
apply
(
this
,
res
);
};
/**
...
...
@@ -375,6 +349,10 @@ exports.fireEvent = function (event, toast, data) {
exports
.
cloneAll
=
function
(
objs
)
{
var
clones
=
[];
if
(
!
Array
.
isArray
(
objs
))
{
objs
=
Array
.
from
(
objs
);
}
for
(
var
obj
of
objs
)
{
clones
.
push
(
exports
.
clone
(
obj
));
}
...
...
@@ -488,11 +466,17 @@ exports.parseEvery = function (spec) {
* @return [ Array<LocalNotification.Action> ]
*/
exports
.
parseActions
=
function
(
obj
)
{
var
actions
=
[],
btn
;
var
spec
=
obj
.
actions
,
actions
=
[],
btn
;
if
(
!
obj
.
actions
)
return
actions
;
if
(
!
spec
)
return
actions
;
if
(
typeof
spec
===
'string'
)
{
var
group
=
LocalNotification
.
ActionGroup
.
lookup
(
spec
);
return
group
?
group
.
actions
:
actions
;
}
for
(
var
action
of
obj
.
actions
)
{
for
(
var
action
of
spec
)
{
if
(
!
action
.
type
||
action
.
type
==
'button'
)
{
btn
=
new
LocalNotification
.
Toast
.
Button
();
}
else
...
...
src/windows/LocalNotificationProxy/LocalNotificationProxy/LocalNotification/ActionGroup.cs
0 → 100644
View file @
3cb3b51e
/*
* Apache 2.0 License
*
* Copyright (c) Sebastian Katzer 2017
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apache License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. Please obtain a copy of the License at
* http://opensource.org/licenses/Apache-2.0/ and read it before using this
* file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*/
namespace
LocalNotificationProxy.LocalNotification
{
using
System.Collections.Generic
;
using
System.Runtime.InteropServices.WindowsRuntime
;
using
global
::
LocalNotificationProxy
.
LocalNotification
.
Toast
;
public
sealed
class
ActionGroup
{
/// <summary>
/// Saves all groups for later lookup.
/// </summary>
private
static
Dictionary
<
string
,
ActionGroup
>
groups
=
new
Dictionary
<
string
,
ActionGroup
>();
/// <summary>
/// Initializes a new instance of the <see cref="ActionGroup"/> class.
/// </summary>
/// <param name="id">The ID of the action group.</param>
/// <param name="actions">The list of actions to group for.</param>
public
ActionGroup
(
string
id
,
[
ReadOnlyArray
]
IAction
[]
actions
)
{
this
.
Id
=
id
;
this
.
Actions
=
actions
;
}
/// <summary>
/// Gets or sets the action group ID.
/// </summary>
public
string
Id
{
get
;
set
;
}
/// <summary>
/// Gets or sets the notification actions.
/// </summary>
public
IAction
[]
Actions
{
get
;
set
;
}
/// <summary>
/// Lookup the action groups with the specified group id.
/// </summary>
/// <param name="id">The ID of the action group to find.</param>
/// <returns>Null if no group was found.</returns>
public
static
ActionGroup
Lookup
(
string
id
)
{
return
groups
[
id
];
}
/// <summary>
/// Register the provided set of actions under the specified group id.
/// </summary>
/// <param name="group">The action group to register.</param>
public
static
void
Register
(
ActionGroup
group
)
{
groups
.
Add
(
group
.
Id
,
group
);
}
/// <summary>
/// Unregister the action group.
/// </summary>
/// <param name="id">The id of the action group to remove.</param>
public
static
void
Unregister
(
string
id
)
{
groups
.
Remove
(
id
);
}
/// <summary>
/// Check if a action group with that id is registered.
/// </summary>
/// <param name="id">The id of the action group to check for.</param>
/// <returns>True if a group with the ID could be found.</returns>
public
static
bool
IsRegistered
(
string
id
)
{
return
groups
.
ContainsKey
(
id
);
}
}
}
src/windows/LocalNotificationProxy/LocalNotificationProxy/LocalNotification/Builder.cs
View file @
3cb3b51e
...
...
@@ -21,8 +21,8 @@
namespace
LocalNotificationProxy.LocalNotification
{
using
Microsoft.Toolkit.Uwp.Notifications
;
using
System.Diagnostics
;
using
Microsoft.Toolkit.Uwp.Notifications
;
using
Windows.UI.Notifications
;
internal
class
Builder
...
...
src/windows/LocalNotificationProxy/LocalNotificationProxy/LocalNotificationProxy.cs
View file @
3cb3b51e
...
...
@@ -107,28 +107,26 @@ namespace LocalNotificationProxy
/// <summary>
/// List of all notifiation by id.
/// </summary>
/// <param name="code">The type of the notifications to return for.</param>
/// <returns>List of numbers</returns>
public
int
[]
Ids
()
public
int
[]
Ids
(
int
code
)
{
return
this
.
manager
.
GetIds
().
ToArray
();
}
var
type
=
Notification
.
Type
.
Unknown
;
/// <summary>
/// List of all scheduled notifiation by id.
/// </summary>
/// <returns>List of numbers</returns>
public
int
[]
ScheduledIds
()
switch
(
code
)
{
return
this
.
manager
.
GetIdsByType
(
Notification
.
Type
.
Scheduled
).
ToArray
();
case
0
:
type
=
Notification
.
Type
.
All
;
break
;
case
1
:
type
=
Notification
.
Type
.
Scheduled
;
break
;
case
2
:
type
=
Notification
.
Type
.
Triggered
;
break
;
}
/// <summary>
/// List of all triggered notifiation by id.
/// </summary>
/// <returns>List of numbers</returns>
public
int
[]
TriggeredIds
()
{
return
this
.
manager
.
GetIdsByType
(
Notification
.
Type
.
Triggered
).
ToArray
();
return
this
.
manager
.
GetIdsByType
(
type
).
ToArray
();
}
#pragma warning disable SA1300 // Element must begin with upper-case letter
...
...
@@ -148,34 +146,29 @@ namespace LocalNotificationProxy
/// <summary>
/// List of (all) notifiation specified by id.
/// </summary>
/// <param name="code">The type of the notifications to return for.</param>
/// <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
();
}
public
Options
[]
Notifications
(
int
code
,
[
ReadOnlyArray
]
int
[]
ids
)
{
var
type
=
Notification
.
Type
.
Unknown
;
switch
(
code
)
{
case
0
:
type
=
Notification
.
Type
.
All
;
break
;
case
1
:
type
=
Notification
.
Type
.
Scheduled
;
break
;
case
2
:
type
=
Notification
.
Type
.
Triggered
;
break
;
case
3
:
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
();
return
this
.
manager
.
GetOptionsByType
(
type
).
ToArray
();
}
}
}
src/windows/LocalNotificationProxy/LocalNotificationProxy/LocalNotificationProxy.csproj
View file @
3cb3b51e
...
...
@@ -111,6 +111,7 @@
</PropertyGroup>
<ItemGroup>
<Compile Include="LocalNotificationProxy.cs" />
<Compile Include="LocalNotification\ActionGroup.cs" />
<Compile Include="LocalNotification\Builder.cs" />
<Compile Include="LocalNotification\Request.cs" />
<Compile Include="LocalNotification\Toast\Button.cs" />
...
...
src/windows/lib.UW/ARM/LocalNotificationProxy.winmd
View file @
3cb3b51e
No preview for this file type
src/windows/lib.UW/x64/LocalNotificationProxy.winmd
View file @
3cb3b51e
No preview for this file type
src/windows/lib.UW/x86/LocalNotificationProxy.winmd
View file @
3cb3b51e
No preview for this file type
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