Commit c4a5a7cb by Sebastián Katzer

Update project

parent ccc2ad34
...@@ -218,7 +218,8 @@ ...@@ -218,7 +218,8 @@
title: 'Scheduled with delay', title: 'Scheduled with delay',
text: 'Test Message 1', text: 'Test Message 1',
at: _5_sec_from_now, at: _5_sec_from_now,
sound: sound sound: sound,
badge: 12
}); });
}; };
......
...@@ -218,7 +218,8 @@ ...@@ -218,7 +218,8 @@
title: 'Scheduled with delay', title: 'Scheduled with delay',
text: 'Test Message 1', text: 'Test Message 1',
at: _5_sec_from_now, at: _5_sec_from_now,
sound: sound sound: sound,
badge: 12
}); });
}; };
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
</Resources> </Resources>
<Applications> <Applications>
<Application Id="de.appplant.localnotification.example" StartPage="www/index.html"> <Application Id="de.appplant.localnotification.example" StartPage="www/index.html">
<m3:VisualElements ToastCapable="true" DisplayName="NotificationExample" Square150x150Logo="images\Square150x150Logo.png" Square44x44Logo="images\Square44x44Logo.png" Description="CordovaApp" ForegroundText="light" BackgroundColor="transparent"> <m3:VisualElements DisplayName="NotificationExample" Square150x150Logo="images\Square150x150Logo.png" Square44x44Logo="images\Square44x44Logo.png" Description="CordovaApp" ForegroundText="light" BackgroundColor="transparent" ToastCapable="true">
<m3:DefaultTile Wide310x150Logo="images\Wide310x150Logo.png" Square71x71Logo="images\Square71x71Logo.png"> <m3:DefaultTile Wide310x150Logo="images\Wide310x150Logo.png" Square71x71Logo="images\Square71x71Logo.png">
<m3:ShowNameOnTiles> <m3:ShowNameOnTiles>
<m3:ShowOn Tile="square150x150Logo" /> <m3:ShowOn Tile="square150x150Logo" />
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- <!--
Licensed to the Apache Software Foundation (ASF) under one Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file or more contributor license agreements. See the NOTICE file
...@@ -16,42 +16,36 @@ ...@@ -16,42 +16,36 @@
KIND, either express or implied. See the License for the KIND, either express or implied. See the License for the
specific language governing permissions and limitations specific language governing permissions and limitations
under the License. under the License.
--> -->
<Package xmlns="http://schemas.microsoft.com/appx/2010/manifest" xmlns:m2="http://schemas.microsoft.com/appx/2013/manifest" xmlns:m3="http://schemas.microsoft.com/appx/2014/manifest" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"> <Package xmlns="http://schemas.microsoft.com/appx/2010/manifest" xmlns:m2="http://schemas.microsoft.com/appx/2013/manifest" xmlns:m3="http://schemas.microsoft.com/appx/2014/manifest" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest">
<Identity Name="e8de53c0-cf2d-11e4-8bb0-9369d008f7b1" Version="1.0.0.0" Publisher="CN=$username$" /> <Identity Name="e8de53c0-cf2d-11e4-8bb0-9369d008f7b1" Version="1.0.0.0" Publisher="CN=$username$" />
<mp:PhoneIdentity PhoneProductId="e8de53c0-cf2d-11e4-8bb0-9369d008f7b1" PhonePublisherId="db093ed5-53b1-45f7-af72-751e8f36ab80" /> <mp:PhoneIdentity PhoneProductId="e8de53c0-cf2d-11e4-8bb0-9369d008f7b1" PhonePublisherId="db093ed5-53b1-45f7-af72-751e8f36ab80" />
<Properties> <Properties>
<DisplayName>NotificationExample</DisplayName> <DisplayName>NotificationExample</DisplayName>
<PublisherDisplayName>$username$</PublisherDisplayName> <PublisherDisplayName>$username$</PublisherDisplayName>
<Logo>images\StoreLogo.png</Logo> <Logo>images\StoreLogo.png</Logo>
</Properties> </Properties>
<Prerequisites> <Prerequisites>
<OSMinVersion>6.3.1</OSMinVersion> <OSMinVersion>6.3.1</OSMinVersion>
<OSMaxVersionTested>6.3.1</OSMaxVersionTested> <OSMaxVersionTested>6.3.1</OSMaxVersionTested>
</Prerequisites> </Prerequisites>
<Resources> <Resources>
<Resource Language="x-generate" /> <Resource Language="x-generate" />
</Resources> </Resources>
<Applications> <Applications>
<Application Id="de.appplant.localnotification.example" StartPage="www/index.html"> <Application Id="de.appplant.localnotification.example" StartPage="www/index.html">
<m3:VisualElements ToastCapable="true" DisplayName="NotificationExample" <m3:VisualElements DisplayName="NotificationExample" Square150x150Logo="images\Square150x150Logo.png" Square44x44Logo="images\Square44x44Logo.png" Description="CordovaApp" ForegroundText="light" BackgroundColor="transparent" ToastCapable="true">
Square150x150Logo="images\Square150x150Logo.png" <m3:DefaultTile Wide310x150Logo="images\Wide310x150Logo.png" Square71x71Logo="images\Square71x71Logo.png">
Square44x44Logo="images\Square44x44Logo.png" <m3:ShowNameOnTiles>
Description="CordovaApp" <m3:ShowOn Tile="square150x150Logo" />
ForegroundText="light" <m3:ShowOn Tile="wide310x150Logo" />
BackgroundColor="transparent"> </m3:ShowNameOnTiles>
<m3:DefaultTile Wide310x150Logo="images\Wide310x150Logo.png" </m3:DefaultTile>
Square71x71Logo="images\Square71x71Logo.png"> <m3:SplashScreen Image="images\SplashScreenPhone.png" />
<m3:ShowNameOnTiles> </m3:VisualElements>
<m3:ShowOn Tile="square150x150Logo" /> </Application>
<m3:ShowOn Tile="wide310x150Logo" /> </Applications>
</m3:ShowNameOnTiles> <Capabilities>
</m3:DefaultTile> <Capability Name="internetClientServer" />
<m3:SplashScreen Image="images\SplashScreenPhone.png" /> </Capabilities>
</m3:VisualElements>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClientServer" />
</Capabilities>
</Package> </Package>
\ No newline at end of file
...@@ -218,7 +218,8 @@ ...@@ -218,7 +218,8 @@
title: 'Scheduled with delay', title: 'Scheduled with delay',
text: 'Test Message 1', text: 'Test Message 1',
at: _5_sec_from_now, at: _5_sec_from_now,
sound: sound sound: sound,
badge: 12
}); });
}; };
......
...@@ -54,8 +54,8 @@ exports.core = { ...@@ -54,8 +54,8 @@ exports.core = {
* 'schedule' or 'update' * 'schedule' or 'update'
*/ */
schedule: function (notifications) { schedule: function (notifications) {
var triggerFn = function (notification) { var triggerFn = function (notification) {
this.updateBadge(notification.badge);
this.fireEvent('trigger', notification); this.fireEvent('trigger', notification);
}; };
...@@ -128,6 +128,25 @@ exports.core = { ...@@ -128,6 +128,25 @@ exports.core = {
}, },
/** /**
* Updates the badge number of the active tile.
*
* @param {Number} badge
* The badge number. Zero will clean the badge.
*/
updateBadge: function (badge) {
var notifications = Windows.UI.Notifications,
type = notifications.BadgeTemplateType.badgeNumber,
xml = notifications.BadgeUpdateManager.getTemplateContent(type),
attrs = xml.getElementsByTagName('badge'),
notification = new notifications.BadgeNotification(xml);
attrs[0].setAttribute('value', badge);
notifications.BadgeUpdateManager.createBadgeUpdaterForApplication()
.update(notification);
},
/**
* Updates a single local notification. * Updates a single local notification.
* *
* @param {Object} notification * @param {Object} notification
......
...@@ -87,58 +87,76 @@ exports.parseSound = function (path) { ...@@ -87,58 +87,76 @@ exports.parseSound = function (path) {
return audio; return audio;
}; };
/** /**
* Builds the xml payload for a local notification based on its options. * Builds the xml payload for a local notification based on its options.
* *
* @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 template = this.buildToastTemplate(options),
var title = options.title, notification = new Windows.Data.Xml.Dom.XmlDocument();
message = options.text || '',
sound = ''; try {
notification.loadXml(template);
if (!title || title === '') { } catch (e) {
title = 'Notification'; console.error(
} 'LocalNotification#schedule',
'Error loading the xml, check for invalid characters.');
if (options.sound) { }
sound = this.parseSound(options.sound);
} // Launch Attribute to enable onClick event
var launchAttr = notification.createAttribute('launch'),
var payload = toastNode = notification.selectSingleNode('/toast');
"<toast> " +
"<visual version='2'>" + launchAttr.value = options.id.toString();
"<binding template='ToastText02'>" + toastNode.attributes.setNamedItem(launchAttr);
"<text id='2'>" + message + "</text>" +
"<text id='1'>" + title + "</text>" + return notification;
"</binding>" + };
"</visual>" +
sound + /**
"<json>" + JSON.stringify(options) + "</json>" + * Builds the toast template with the right style depend on the options.
"</toast>"; *
* @param {Object} options
var notification = new Windows.Data.Xml.Dom.XmlDocument(); * Local notification properties
*
try { * @return String
notification.loadXml(payload); */
} catch (e) { exports.buildToastTemplate = function (options) {
console.error( var title = options.title,
'LocalNotification#schedule', message = options.text || '',
'Error loading the xml, check for invalid characters.'); json = JSON.stringify(options),
} sound = '';
// Launch Attribute to enable onClick event if (options.sound && options.sound !== '') {
var launchAttr = notification.createAttribute('launch'), sound = this.parseSound(options.sound);
toastNode = notification.selectSingleNode('/toast'); }
launchAttr.value = options.id.toString(); if (title && title !== '') {
toastNode.attributes.setNamedItem(launchAttr); return "<toast>" +
"<visual>" +
return notification; "<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>";
}
}; };
/** /**
......
...@@ -218,7 +218,8 @@ ...@@ -218,7 +218,8 @@
title: 'Scheduled with delay', title: 'Scheduled with delay',
text: 'Test Message 1', text: 'Test Message 1',
at: _5_sec_from_now, at: _5_sec_from_now,
sound: sound sound: sound,
badge: 12
}); });
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment