Commit 33ad4c78 authored by Sebastián Katzer's avatar Sebastián Katzer
Browse files

Support badge property on windows platform

parent cb3e2e80
Loading
Loading
Loading
Loading
+20 −1
Changes for src/windows/LocalNotificationCore.js: 20 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -54,8 +54,8 @@ exports.core = {
     *      'schedule' or 'update'
     */
    schedule: function (notifications) {

        var triggerFn = function (notification) {
            this.updateBadge(notification.badge);
            this.fireEvent('trigger', notification);
        };

@@ -127,6 +127,25 @@ exports.core = {
        this.scheduleLocalNotification(notification, properties);
    },

    /**
     * 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.
     *