Last active
March 11, 2016 14:22
-
-
Save boyofgreen/ce96cef1b403701e8606 to your computer and use it in GitHub Desktop.
notification inside a Windows 10 app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (typeof Windows !== 'undefined'&& typeof Windows.UI !== 'undefined' && typeof Windows.UI.Notifications !== 'undefined') { | |
// Construct the toast notification content | |
var toastContent = new Windows.Data.Xml.Dom.XmlDocument(); | |
var toast = toastContent.createElement("toast"); | |
toastContent.appendChild(toast); | |
var visual = toastContent.createElement("visual"); | |
toast.appendChild(visual); | |
var binding = toastContent.createElement("binding"); | |
binding.setAttribute("template", "ToastGeneric"); | |
visual.appendChild(binding); | |
// Title text | |
var text = toastContent.createElement("text"); | |
text.innerText = "This is the message for my toast"; | |
binding.appendChild(text); | |
// TODO: Add up to two more text elements | |
// Override the app logo | |
var appLogo = toastContent.createElement("image"); | |
appLogo.setAttribute("placement", "appLogoOverride"); | |
appLogo.setAttribute("src", "https://unsplash.it/150/150/?random"); | |
appLogo.setAttribute("alt", "random graphic"); | |
binding.appendChild(appLogo); | |
// And send the toast notification | |
var notifications = Windows.UI.Notifications; | |
var toast = new notifications.ToastNotification(toastContent); | |
notifications.ToastNotificationManager.createToastNotifier().show(toast); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment