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
30e35884
Commit
30e35884
authored
Apr 08, 2015
by
Sebastián Katzer
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:katzer/cordova-plugin-local-notifications
parents
c3520580
f47e405b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
19 deletions
+69
-19
LocalNotificationCore.js
src/windows/LocalNotificationCore.js
+8
-0
LocalNotificationUtil.js
src/windows/LocalNotificationUtil.js
+61
-19
No files found.
src/windows/LocalNotificationCore.js
View file @
30e35884
...
...
@@ -200,7 +200,9 @@ exports.core = {
clearLocalNotification
:
function
(
id
)
{
var
notification
=
this
.
getAll
([
id
])[
0
];
try
{
this
.
getToastHistory
().
remove
(
'Toast'
+
id
);
}
catch
(
e
)
{
/*Only Phones support the NotificationHistory*/
}
if
(
this
.
isRepeating
(
notification
))
return
;
...
...
@@ -220,7 +222,9 @@ exports.core = {
this
.
clearLocalNotification
(
ids
[
i
]);
}
try
{
this
.
getToastHistory
().
clear
();
}
catch
(
e
)
{
/*Only Phones support the NotificationHistory*/
}
this
.
fireEvent
(
'clearall'
);
},
...
...
@@ -251,7 +255,9 @@ exports.core = {
history
=
this
.
getToastHistory
(),
toasts
=
this
.
getScheduledToasts
();
try
{
history
.
remove
(
'Toast'
+
id
);
}
catch
(
e
)
{
/*Only Phones support the NotificationHistory*/
}
for
(
var
i
=
0
;
i
<
toasts
.
length
;
i
++
)
{
var
toast
=
toasts
[
i
];
...
...
@@ -272,7 +278,9 @@ exports.core = {
this
.
cancelLocalNotification
(
ids
[
i
]);
}
try
{
this
.
getToastHistory
().
clear
();
}
catch
(
e
)
{
/*Only Phones support the NotificationHistory*/
}
this
.
fireEvent
(
'cancelall'
);
},
...
...
src/windows/LocalNotificationUtil.js
View file @
30e35884
...
...
@@ -86,20 +86,52 @@ exports.isRepeating = function (notification) {
* @param {String} path
* Relative path to sound resource
*
* @return {String}
URI to
Sound-File
* @return {String}
XML Tag for
Sound-File
*/
exports
.
parseSound
=
function
(
path
)
{
if
(
!
path
.
match
(
/^file/
))
return
''
;
var
uri
=
this
.
parseUri
(
path
),
audio
=
"<audio src="
+
uri
+
" loop='false'/>"
;
return
audio
;
};
/**
* Parses image file path.
*
* @param {String} path
* Relative path to image resource
*
* @return {String} XML-Tag for Image-File
*/
exports
.
parseImage
=
function
(
path
)
{
if
(
!
path
.
match
(
/^file/
))
return
''
;
var
uri
=
this
.
parseUri
(
path
),
image
=
"<image id='1' src="
+
uri
+
" />"
;
return
image
;
};
/**
* Parses file path to URI.
*
* @param {String} path
* Relative path to a resource
*
* @return {String} URI to File
*/
exports
.
parseUri
=
function
(
path
)
{
var
pkg
=
Windows
.
ApplicationModel
.
Package
.
current
,
pkgId
=
pkg
.
id
,
pkgName
=
pkgId
.
name
;
if
(
!
path
.
match
(
/^file/
))
return
;
var
sound
=
"'ms-appx://"
+
pkgName
+
"/www/"
+
path
.
slice
(
6
,
path
.
length
)
+
"'"
,
audio
=
"<audio src="
+
sound
+
" loop='false'/>"
;
var
uri
=
"'ms-appx://"
+
pkgName
+
"/www"
+
path
.
slice
(
6
,
path
.
length
)
+
"'"
;
return
audio
;
return
uri
;
};
/**
...
...
@@ -150,28 +182,38 @@ exports.buildToastTemplate = function (options) {
sound
=
this
.
parseSound
(
options
.
sound
);
}
var
templateName
=
"ToastText"
,
imageNode
;
if
(
options
.
icon
&&
options
.
icon
!==
''
)
{
imageNode
=
this
.
parseImage
(
options
.
icon
);
// template with Image
if
(
imageNode
!==
''
)
{
templateName
=
"ToastImageAndText"
;
};
}
else
{
imageNode
=
""
;
}
var
bindingNode
;
if
(
title
&&
title
!==
''
)
{
return
"<toast>"
+
"<visual>"
+
"<binding template='ToastText02'>"
+
bindingNode
=
"<binding template='"
+
templateName
+
"02'>"
+
imageNode
+
"<text id='1'>"
+
title
+
"</text>"
+
"<text id='2'>"
+
message
+
"</text>"
+
"</binding>"
+
"</visual>"
+
sound
+
"<json>"
+
json
+
"</json>"
+
"</toast>"
;
"</binding>"
;
}
else
{
bindingNode
=
"<binding template='"
+
templateName
+
"01'>"
+
imageNode
+
"<text id='1'>"
+
message
+
"</text>"
+
"</binding>"
;
}
return
"<toast>"
+
"<visual>"
+
"<binding template='ToastText01'>"
+
"<text id='1'>"
+
message
+
"</text>"
+
"</binding>"
+
bindingNode
+
"</visual>"
+
sound
+
"<json>"
+
json
+
"</json>"
+
"</toast>"
;
}
};
/**
...
...
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