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
ad102c3e
Commit
ad102c3e
authored
Aug 11, 2017
by
Sebastián Katzer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support for input actions
parent
78bf5452
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
185 additions
and
36 deletions
+185
-36
LocalNotificationProxy.js
src/windows/LocalNotificationProxy.js
+29
-16
Builder.cs
...Proxy/LocalNotificationProxy/LocalNotification/Builder.cs
+5
-0
Button.cs
...nProxy/LocalNotificationProxy/LocalNotification/Button.cs
+4
-6
Content.cs
...Proxy/LocalNotificationProxy/LocalNotification/Content.cs
+43
-3
IAction.cs
...Proxy/LocalNotificationProxy/LocalNotification/IAction.cs
+41
-0
Input.cs
...onProxy/LocalNotificationProxy/LocalNotification/Input.cs
+56
-0
Options.cs
...Proxy/LocalNotificationProxy/LocalNotification/Options.cs
+2
-2
LocalNotificationProxy.csproj
...roxy/LocalNotificationProxy/LocalNotificationProxy.csproj
+2
-0
local-notification-util.js
www/local-notification-util.js
+3
-9
No files found.
src/windows/LocalNotificationProxy.js
View file @
ad102c3e
...
@@ -60,33 +60,34 @@ exports.request = function (success, error) {
...
@@ -60,33 +60,34 @@ exports.request = function (success, error) {
* @return [ Void ]
* @return [ Void ]
*/
*/
exports
.
schedule
=
function
(
success
,
error
,
args
)
{
exports
.
schedule
=
function
(
success
,
error
,
args
)
{
var
options
=
[],
butt
ons
=
[];
var
options
=
[],
acti
ons
=
[];
for
(
var
i
=
0
,
props
,
opts
;
i
<
args
.
length
;
i
++
)
{
for
(
var
i
=
0
,
props
,
opts
;
i
<
args
.
length
;
i
++
)
{
props
=
args
[
i
];
props
=
args
[
i
];
opts
=
new
LocalNotification
.
Options
();
opts
=
new
LocalNotification
.
Options
();
for
(
var
prop
in
opts
)
{
for
(
var
prop
in
opts
)
{
if
(
props
[
prop
])
{
if
(
prop
!=
'actions'
&&
props
[
prop
])
opts
[
prop
]
=
props
[
prop
];
opts
[
prop
]
=
props
[
prop
];
}
}
}
for
(
var
j
=
0
,
action
;
j
<
props
.
actions
.
length
;
j
++
)
{
for
(
var
j
=
0
,
action
,
btn
;
j
<
props
.
actions
.
length
;
j
++
)
{
action
=
props
.
actions
[
j
];
action
=
props
.
actions
[
j
];
if
(
!
action
.
type
||
action
.
type
==
'button'
)
{
if
(
!
action
.
type
||
action
.
type
==
'button'
)
{
var
butto
n
=
new
LocalNotification
.
Button
();
bt
n
=
new
LocalNotification
.
Button
();
}
else
button
.
id
=
action
.
id
;
if
(
action
.
type
==
'input'
)
{
b
utton
.
title
=
action
.
title
;
b
tn
=
new
LocalNotification
.
Input
()
;
button
.
launch
=
action
.
launch
;
}
buttons
.
push
(
button
);
for
(
prop
in
btn
)
{
if
(
action
[
prop
])
btn
[
prop
]
=
action
[
prop
];
}
}
actions
.
push
(
btn
);
}
}
opts
.
buttons
=
butt
ons
;
opts
.
actions
=
acti
ons
;
options
.
push
(
opts
);
options
.
push
(
opts
);
}
}
...
@@ -103,17 +104,29 @@ exports.schedule = function (success, error, args) {
...
@@ -103,17 +104,29 @@ exports.schedule = function (success, error, args) {
*
*
* @return [ Void ]
* @return [ Void ]
*/
*/
exports
.
clicked
=
function
(
xml
)
{
exports
.
clicked
=
function
(
xml
,
input
)
{
var
toast
=
LocalNotification
.
Options
.
parse
(
xml
),
var
toast
=
LocalNotification
.
Options
.
parse
(
xml
),
event
=
toast
.
action
||
'click'
;
event
=
toast
.
action
||
'click'
,
e
=
{
event
:
event
};
if
(
input
&&
input
.
size
>
0
)
{
var
it
=
input
.
first
();
e
.
text
=
it
.
current
.
value
;
while
(
it
.
hasCurrent
)
{
e
[
it
.
current
.
key
]
=
it
.
current
.
value
;
it
.
moveNext
();
}
}
cordova
.
plugins
.
notification
.
local
.
core
.
fireEvent
(
event
,
toast
);
cordova
.
plugins
.
notification
.
local
.
core
.
fireEvent
(
event
,
toast
,
e
);
};
};
// Handle onclick event
// Handle onclick event
document
.
addEventListener
(
'activated'
,
function
(
e
)
{
document
.
addEventListener
(
'activated'
,
function
(
e
)
{
if
(
e
.
kind
==
ActivationKind
.
toastNotification
)
{
if
(
e
.
kind
==
ActivationKind
.
toastNotification
)
{
exports
.
clicked
(
e
.
raw
.
argument
);
exports
.
clicked
(
e
.
raw
.
argument
,
e
.
raw
.
userInput
);
}
}
},
false
);
},
false
);
...
...
src/windows/LocalNotificationProxy/LocalNotificationProxy/LocalNotification/Builder.cs
View file @
ad102c3e
...
@@ -117,6 +117,11 @@ namespace LocalNotificationProxy.LocalNotification
...
@@ -117,6 +117,11 @@ namespace LocalNotificationProxy.LocalNotification
/// <param name="toast">Tho toast to extend for.</param>
/// <param name="toast">Tho toast to extend for.</param>
private
void
AddActions
(
ToastContent
toast
)
private
void
AddActions
(
ToastContent
toast
)
{
{
foreach
(
var
btn
in
this
.
Content
.
Inputs
)
{
(
toast
.
Actions
as
ToastActionsCustom
).
Inputs
.
Add
(
btn
);
}
foreach
(
var
btn
in
this
.
Content
.
Buttons
)
foreach
(
var
btn
in
this
.
Content
.
Buttons
)
{
{
(
toast
.
Actions
as
ToastActionsCustom
).
Buttons
.
Add
(
btn
);
(
toast
.
Actions
as
ToastActionsCustom
).
Buttons
.
Add
(
btn
);
...
...
src/windows/LocalNotificationProxy/LocalNotificationProxy/LocalNotification/Button.cs
View file @
ad102c3e
...
@@ -21,23 +21,21 @@
...
@@ -21,23 +21,21 @@
namespace
LocalNotificationProxy.LocalNotification
namespace
LocalNotificationProxy.LocalNotification
{
{
using
Microsoft.Toolkit.Uwp.Notifications
;
public
sealed
class
Button
:
IAction
public
sealed
class
Button
{
{
/// <summary>
/// <summary>
/// Gets or sets
button
ID.
/// Gets or sets
the
ID.
/// </summary>
/// </summary>
public
string
ID
{
get
;
set
;
}
public
string
ID
{
get
;
set
;
}
/// <summary>
/// <summary>
/// Gets or sets
button
title.
/// Gets or sets
the
title.
/// </summary>
/// </summary>
public
string
Title
{
get
;
set
;
}
public
string
Title
{
get
;
set
;
}
/// <summary>
/// <summary>
/// Gets or sets a value indicating whether to launch the app.
/// Gets or sets a value indicating whether to launch the app.
/// </summary>
/// </summary>
public
bool
Launch
{
get
;
set
;
}
public
bool
Launch
{
get
;
set
;
}
=
true
;
}
}
}
}
src/windows/LocalNotificationProxy/LocalNotificationProxy/LocalNotification/Content.cs
View file @
ad102c3e
...
@@ -176,20 +176,60 @@
...
@@ -176,20 +176,60 @@
{
{
var
buttons
=
new
List
<
ToastButton
>();
var
buttons
=
new
List
<
ToastButton
>();
foreach
(
var
action
in
this
.
Options
.
Butt
ons
)
foreach
(
var
action
in
this
.
Options
.
Acti
ons
)
{
{
buttons
.
Add
(
if
(
action
is
Button
)
new
ToastButton
(
action
.
Title
,
this
.
Options
.
GetXml
(
action
.
ID
))
{
buttons
.
Add
(
new
ToastButton
(
action
.
Title
,
this
.
Options
.
GetXml
(
action
.
ID
))
{
{
ActivationType
=
action
.
Launch
?
ToastActivationType
.
Foreground
:
ToastActivationType
.
Background
ActivationType
=
action
.
Launch
?
ToastActivationType
.
Foreground
:
ToastActivationType
.
Background
});
});
}
}
else
if
(
action
is
Input
&&
(
action
as
Input
).
SubmitTitle
!=
null
)
{
var
input
=
action
as
Input
;
buttons
.
Add
(
new
ToastButton
(
input
.
SubmitTitle
,
this
.
Options
.
GetXml
(
input
.
ID
))
{
ActivationType
=
input
.
Launch
?
ToastActivationType
.
Foreground
:
ToastActivationType
.
Background
,
TextBoxId
=
input
.
ID
});
}
}
return
buttons
;
return
buttons
;
}
}
}
}
/// <summary>
/// <summary>
/// Gets all toast inputs.
/// </summary>
public
List
<
ToastTextBox
>
Inputs
{
get
{
var
inputs
=
new
List
<
ToastTextBox
>();
foreach
(
var
action
in
this
.
Options
.
Actions
)
{
if
(!(
action
is
Input
))
{
continue
;
}
inputs
.
Add
(
new
ToastTextBox
(
action
.
ID
)
{
Title
=
action
.
Title
,
PlaceholderContent
=
(
action
as
Input
).
EmptyText
,
DefaultInput
=
(
action
as
Input
).
DefaultValue
});
}
return
inputs
;
}
}
/// <summary>
/// Gets the date when to trigger the notification.
/// Gets the date when to trigger the notification.
/// </summary>
/// </summary>
public
DateTime
Date
public
DateTime
Date
...
...
src/windows/LocalNotificationProxy/LocalNotificationProxy/LocalNotification/IAction.cs
0 → 100644
View file @
ad102c3e
/*
* 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
{
public
interface
IAction
{
/// <summary>
/// Gets or sets the ID.
/// </summary>
string
ID
{
get
;
set
;
}
/// <summary>
/// Gets or sets the title.
/// </summary>
string
Title
{
get
;
set
;
}
/// <summary>
/// Gets or sets a value indicating whether to launch the app.
/// </summary>
bool
Launch
{
get
;
set
;
}
}
}
src/windows/LocalNotificationProxy/LocalNotificationProxy/LocalNotification/Input.cs
0 → 100644
View file @
ad102c3e
/*
* 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
{
public
sealed
class
Input
:
IAction
{
/// <summary>
/// Gets or sets the ID.
/// </summary>
public
string
ID
{
get
;
set
;
}
/// <summary>
/// Gets or sets the title.
/// </summary>
public
string
Title
{
get
;
set
;
}
/// <summary>
/// Gets or sets the title of the submit button.
/// </summary>
public
string
SubmitTitle
{
get
;
set
;
}
/// <summary>
/// Gets or sets placeholder text.
/// </summary>
public
string
EmptyText
{
get
;
set
;
}
/// <summary>
/// Gets or sets the default text.
/// </summary>
public
string
DefaultValue
{
get
;
set
;
}
/// <summary>
/// Gets or sets a value indicating whether to launch the app.
/// </summary>
public
bool
Launch
{
get
;
set
;
}
=
true
;
}
}
src/windows/LocalNotificationProxy/LocalNotificationProxy/LocalNotification/Options.cs
View file @
ad102c3e
...
@@ -81,9 +81,9 @@ namespace LocalNotificationProxy.LocalNotification
...
@@ -81,9 +81,9 @@ namespace LocalNotificationProxy.LocalNotification
public
string
[]
Attachments
{
get
;
set
;
}
public
string
[]
Attachments
{
get
;
set
;
}
/// <summary>
/// <summary>
/// Gets or sets the notification
butt
ons.
/// Gets or sets the notification
acti
ons.
/// </summary>
/// </summary>
public
Button
[]
Butt
ons
{
get
;
set
;
}
public
IAction
[]
Acti
ons
{
get
;
set
;
}
/// <summary>
/// <summary>
/// Deserializes the XML string into an instance of Options.
/// Deserializes the XML string into an instance of Options.
...
...
src/windows/LocalNotificationProxy/LocalNotificationProxy/LocalNotificationProxy.csproj
View file @
ad102c3e
...
@@ -114,6 +114,8 @@
...
@@ -114,6 +114,8 @@
<Compile Include="LocalNotification\Builder.cs" />
<Compile Include="LocalNotification\Builder.cs" />
<Compile Include="LocalNotification\Button.cs" />
<Compile Include="LocalNotification\Button.cs" />
<Compile Include="LocalNotification\Content.cs" />
<Compile Include="LocalNotification\Content.cs" />
<Compile Include="LocalNotification\IAction.cs" />
<Compile Include="LocalNotification\Input.cs" />
<Compile Include="LocalNotification\Options.cs" />
<Compile Include="LocalNotification\Options.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
</ItemGroup>
...
...
www/local-notification-util.js
View file @
ad102c3e
...
@@ -180,14 +180,10 @@ exports.convertActions = function (options) {
...
@@ -180,14 +180,10 @@ exports.convertActions = function (options) {
if
(
!
options
.
actions
)
if
(
!
options
.
actions
)
return
null
;
return
null
;
var
MAX_ACTIONS
=
(
device
.
platform
===
'iOS'
)
?
4
:
3
,
var
actions
=
[];
actions
=
[];
if
(
options
.
actions
.
length
>
MAX_ACTIONS
)
for
(
var
i
=
0
,
action
;
i
<
options
.
actions
.
length
;
i
++
)
{
console
.
warn
(
'Count of actions exceeded count of '
+
MAX_ACTIONS
);
action
=
options
.
actions
[
i
];
for
(
var
i
=
0
;
i
<
options
.
actions
.
length
&&
MAX_ACTIONS
>
0
;
i
++
)
{
var
action
=
options
.
actions
[
i
];
if
(
!
action
.
id
)
{
if
(
!
action
.
id
)
{
console
.
warn
(
console
.
warn
(
...
@@ -196,10 +192,8 @@ exports.convertActions = function (options) {
...
@@ -196,10 +192,8 @@ exports.convertActions = function (options) {
}
}
action
.
id
=
action
.
id
.
toString
();
action
.
id
=
action
.
id
.
toString
();
action
.
title
=
(
action
.
title
||
action
.
id
).
toString
();
actions
.
push
(
action
);
actions
.
push
(
action
);
MAX_ACTIONS
--
;
}
}
options
.
category
=
(
options
.
category
||
'DEFAULT_GROUP'
).
toString
();
options
.
category
=
(
options
.
category
||
'DEFAULT_GROUP'
).
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