|
@@ -93,38 +93,14 @@ exports.parseSound = function (path) {
|
|
|
* @param {Object} options
|
|
* @param {Object} options
|
|
|
* Local notification properties
|
|
* Local notification properties
|
|
|
*
|
|
*
|
|
|
- * @return {String}
|
|
|
|
|
- * Windows.Data.Xml.Dom.XmlDocument
|
|
|
|
|
|
|
+ * @return Windows.Data.Xml.Dom.XmlDocument
|
|
|
*/
|
|
*/
|
|
|
exports.build = function (options) {
|
|
exports.build = function (options) {
|
|
|
- var title = options.title,
|
|
|
|
|
- message = options.text || '',
|
|
|
|
|
- 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();
|
|
|
|
|
|
|
+ var template = this.buildToastTemplate(options),
|
|
|
|
|
+ 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',
|
|
@@ -141,6 +117,48 @@ exports.build = function (options) {
|
|
|
return notification;
|
|
return notification;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * 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.
|
|
|
*/
|
|
*/
|