Skip to content

Instantly share code, notes, and snippets.

@domenic
Created October 9, 2012 21:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save domenic/3861617 to your computer and use it in GitHub Desktop.
Save domenic/3861617 to your computer and use it in GitHub Desktop.
Windows 8 toasts
var template = Windows.UI.Notifications.ToastTemplateType.toastImageAndText03;
var toastXml = Windows.UI.Notifications.ToastNotificationManager.getTemplateContent(template);
var imageEl = toastXml.getElementsByTagName("image")[0];
imageEl.setAttribute("src", "ms-appx:///images/toast-image.png");
imageEl.setAttribute("alt", "Alternate text");
var textEls = toastXml.getElementsByTagName("text");
textEls[0].innerText = "First line!";
textEls[1].innerText = "Second line!";
var toast = new Windows.UI.Notifications.ToastNotification(toastXml);
var toastNotifier = Windows.UI.Notifications.ToastNotificationManager.createToastNotifier();
toastNotifier.show(toast);
var showToast = require("WinningJS/lib/ui/toasts").show;
showToast({
type: 3,
image: {
src: "ms-appx:///images/toast-image.png",
alt: "Alternate text"
},
text: ["First line!", "Second line!"]
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment