From 5f72b571ebabd1924049f544fc6bfe4a554ae4fc Mon Sep 17 00:00:00 2001 From: Rob Paveza Date: Tue, 5 May 2015 10:40:27 -0700 Subject: [PATCH] CB-8946: Added the "WindowsToastCapable" preference to indicate that the app can support toasts. This is to support the Local Notifications plugin. --- template/cordova/lib/prepare.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/template/cordova/lib/prepare.js b/template/cordova/lib/prepare.js index 7bec13d4..d884cb76 100644 --- a/template/cordova/lib/prepare.js +++ b/template/cordova/lib/prepare.js @@ -86,6 +86,7 @@ function updateManifestFile (config, manifestPath, namespacePrefix) { sortCapabilities(manifest); applyAccessRules(config, manifest); applyBackgroundColor(config, manifest, namespacePrefix); + applyToastCapability(config, manifest, namespacePrefix); //Write out manifest @@ -386,3 +387,24 @@ function applyBackgroundColor (config, manifest, xmlnsPrefix) { visualElems.attrib.BackgroundColor = refineColor(bgColor); } } + +/** + * Applies the ToastCapable attribute to the VisualElements tag + * @param config {ConfigParser} The configuration reader + * @param manifest {et.ElementTree} The manifest file + * @namespacePrefix {String} The XML namespace for the VisualElements tag, in the form 'm2:' + */ +function applyToastCapability(config, manifest, namespacePrefix) { + var isToastCapable = config.getPreference('WindowsToastCapable'); + isToastCapable = (isToastCapable && isToastCapable.toString().toLowerCase() === 'true'); + + var visualElementsName = './/' + namespacePrefix + 'VisualElements'; + var visualElems = manifest.find(visualElementsName); + + if (isToastCapable) { + visualElems.attrib.ToastCapable = 'true'; + } + else { + delete visualElems.attrib.ToastCapable; + } +}