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
4abccaf3
Commit
4abccaf3
authored
Sep 28, 2017
by
Sebastián Katzer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Serialize/Deserialize trigger option on windows
parent
cbdcee1b
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
1 deletions
+55
-1
LocalNotificationProxy.js
src/windows/LocalNotificationProxy.js
+4
-1
Options.cs
...Proxy/LocalNotificationProxy/LocalNotification/Options.cs
+2
-0
Trigger.cs
...Proxy/LocalNotificationProxy/LocalNotification/Trigger.cs
+49
-0
No files found.
src/windows/LocalNotificationProxy.js
View file @
4abccaf3
...
...
@@ -393,14 +393,17 @@ exports.cloneAll = function (objs) {
*/
exports
.
clone
=
function
(
obj
)
{
var
ignore
=
[
'action'
],
dclone
=
[
'trigger'
],
clone
=
{};
if
(
obj
===
null
)
return
null
;
for
(
var
prop
in
obj
)
{
if
(
ignore
.
includes
(
prop
)
||
typeof
obj
[
prop
]
===
'function'
)
continue
;
try
{
clone
[
prop
]
=
obj
[
prop
];
clone
[
prop
]
=
dclone
.
includes
(
prop
)
?
exports
.
clone
(
obj
[
prop
])
:
obj
[
prop
];
}
catch
(
e
)
{
clone
[
prop
]
=
null
;
}
...
...
src/windows/LocalNotificationProxy/LocalNotificationProxy/LocalNotification/Options.cs
View file @
4abccaf3
...
...
@@ -105,6 +105,7 @@ namespace LocalNotificationProxy.LocalNotification
options
.
Id
=
int
.
Parse
(
node
.
GetAttribute
(
"id"
));
options
.
Badge
=
int
.
Parse
(
node
.
GetAttribute
(
"badge"
));
options
.
Trigger
=
Trigger
.
Parse
(
node
.
GetAttribute
(
"trigger"
));
if
(
node
.
GetAttributeNode
(
"text"
)
!=
null
)
{
...
...
@@ -169,6 +170,7 @@ namespace LocalNotificationProxy.LocalNotification
node
.
SetAttribute
(
"id"
,
this
.
Id
.
ToString
());
node
.
SetAttribute
(
"badge"
,
this
.
Badge
.
ToString
());
node
.
SetAttribute
(
"trigger"
,
this
.
Trigger
.
GetXml
());
if
(
this
.
Title
!=
null
)
{
...
...
src/windows/LocalNotificationProxy/LocalNotificationProxy/LocalNotification/Trigger.cs
View file @
4abccaf3
...
...
@@ -19,6 +19,8 @@
* limitations under the License.
*/
using
Windows.Data.Xml.Dom
;
namespace
LocalNotificationProxy.LocalNotification
{
public
sealed
class
Trigger
...
...
@@ -52,5 +54,52 @@ namespace LocalNotificationProxy.LocalNotification
/// Gets or sets trigger interval.
/// </summary>
public
string
Every
{
get
;
set
;
}
/// <summary>
/// Deserializes the XML string into an instance of Trigger.
/// </summary>
/// <param name="xml">The serialized instance of Options as an xml string.</param>
/// <returns>An instance where all properties have been assigned.</returns>
internal
static
Trigger
Parse
(
string
xml
)
{
var
doc
=
new
XmlDocument
();
doc
.
LoadXml
(
xml
);
var
trigger
=
new
Trigger
();
var
node
=
doc
.
DocumentElement
;
trigger
.
At
=
long
.
Parse
(
node
.
GetAttribute
(
"at"
));
trigger
.
In
=
long
.
Parse
(
node
.
GetAttribute
(
"in"
));
trigger
.
Count
=
int
.
Parse
(
node
.
GetAttribute
(
"count"
));
trigger
.
Occurrence
=
int
.
Parse
(
node
.
GetAttribute
(
"occurrence"
));
if
(
node
.
GetAttributeNode
(
"every"
)
!=
null
)
{
trigger
.
Every
=
node
.
GetAttribute
(
"every"
);
}
return
trigger
;
}
/// <summary>
/// Gets the instance as an serialized xml element.
/// </summary>
/// <returns>Element with all property values set as attributes.</returns>
internal
string
GetXml
()
{
var
node
=
new
XmlDocument
().
CreateElement
(
"trigger"
);
node
.
SetAttribute
(
"at"
,
this
.
At
.
ToString
());
node
.
SetAttribute
(
"in"
,
this
.
In
.
ToString
());
node
.
SetAttribute
(
"count"
,
this
.
Count
.
ToString
());
node
.
SetAttribute
(
"occurrence"
,
this
.
Occurrence
.
ToString
());
if
(
this
.
Every
!=
null
)
{
node
.
SetAttribute
(
"every"
,
this
.
Every
);
}
return
node
.
GetXml
();
}
}
}
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