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
cb3e2e80
Commit
cb3e2e80
authored
Mar 21, 2015
by
Sebastián Katzer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Different template if toast has no title
parent
93eb2ec9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
28 deletions
+46
-28
LocalNotificationUtil.js
src/windows/LocalNotificationUtil.js
+46
-28
No files found.
src/windows/LocalNotificationUtil.js
View file @
cb3e2e80
...
@@ -93,38 +93,14 @@ exports.parseSound = function (path) {
...
@@ -93,38 +93,14 @@ exports.parseSound = function (path) {
* @param {Object} options
* @param {Object} options
* Local notification properties
* Local notification properties
*
*
* @return {String}
* @return Windows.Data.Xml.Dom.XmlDocument
* Windows.Data.Xml.Dom.XmlDocument
*/
*/
exports
.
build
=
function
(
options
)
{
exports
.
build
=
function
(
options
)
{
var
title
=
options
.
title
,
var
template
=
this
.
buildToastTemplate
(
options
),
message
=
options
.
text
||
''
,
notification
=
new
Windows
.
Data
.
Xml
.
Dom
.
XmlDocument
();
sound
=
''
;
if
(
!
title
||
title
===
''
)
{
title
=
'Notification'
;
}
if
(
options
.
sound
)
{
sound
=
this
.
parseSound
(
options
.
sound
);
}
var
payload
=
"<toast> "
+
"<visual version='2'>"
+
"<binding template='ToastText02'>"
+
"<text id='2'>"
+
message
+
"</text>"
+
"<text id='1'>"
+
title
+
"</text>"
+
"</binding>"
+
"</visual>"
+
sound
+
"<json>"
+
JSON
.
stringify
(
options
)
+
"</json>"
+
"</toast>"
;
var
notification
=
new
Windows
.
Data
.
Xml
.
Dom
.
XmlDocument
();
try
{
try
{
notification
.
loadXml
(
payload
);
notification
.
loadXml
(
template
);
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
error
(
console
.
error
(
'LocalNotification#schedule'
,
'LocalNotification#schedule'
,
...
@@ -142,6 +118,48 @@ exports.build = function (options) {
...
@@ -142,6 +118,48 @@ exports.build = function (options) {
};
};
/**
/**
* Builds the toast template with the right style depend on the options.
*
* @param {Object} options
* Local notification properties
*
* @return String
*/
exports
.
buildToastTemplate
=
function
(
options
)
{
var
title
=
options
.
title
,
message
=
options
.
text
||
''
,
json
=
JSON
.
stringify
(
options
),
sound
=
''
;
if
(
options
.
sound
&&
options
.
sound
!==
''
)
{
sound
=
this
.
parseSound
(
options
.
sound
);
}
if
(
title
&&
title
!==
''
)
{
return
"<toast>"
+
"<visual>"
+
"<binding template='ToastText02'>"
+
"<text id='1'>"
+
title
+
"</text>"
+
"<text id='2'>"
+
message
+
"</text>"
+
"</binding>"
+
"</visual>"
+
sound
+
"<json>"
+
json
+
"</json>"
+
"</toast>"
;
}
else
{
return
"<toast>"
+
"<visual>"
+
"<binding template='ToastText01'>"
+
"<text id='1'>"
+
message
+
"</text>"
+
"</binding>"
+
"</visual>"
+
sound
+
"<json>"
+
json
+
"</json>"
+
"</toast>"
;
}
};
/**
* Short-hand method for the toast notification history.
* Short-hand method for the toast notification history.
*/
*/
exports
.
getToastHistory
=
function
()
{
exports
.
getToastHistory
=
function
()
{
...
...
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