Toast Notifications In Universal Windows Apps

In this article, you will learn about toast notifications in Universal Windows apps.

Sharing some good collective information on Toast Notifications in Universal Windows Apps.

  • Types:

    Glance(Consume) : Toast is like "Update Available" or "New features available".
    Act (Chase or take action) :
    Toast invites you to begin or complete the task.
    The toast is the app's door by chasing (clicking) it.
    Additional actions enable the users to perform a simple task without context switching.

  • Toast Templates

    All the templates are available, which are for Windows phone and store apps. Now, they have merged together. If existing legacy templates don't fulfill your needs, new templates are also available.

    Adaptive Templates

  • Sending Toasts:

    Scheduled : Set the template and tile with "ScheduledToastNotification", toast can also be set to recurring.
    Local : Send from the foreground/background app.
    Push : Use Push services.
    1. void SendToast()   
    2. {  
    3.     //Make toast  
    4.     var toastTemplate = ToastTemplateType.ToastText01;  
    5.     var xml = ToastNotificationManager.GetTemplateContent(toastTemplate);  
    6.     xml.DocumentElement.SetAttribute("launch""Args");  
    7.     //setting up value  
    8.     var toastText = xml.CreateTextNode("This is Notification Message");  
    9.     var elements = xml.GetElementsByTagName("text");  
    10.     elements[0].AppendChild(toastText);  
    11.     //Showing toast  
    12.     var toast = new ToastNotification(xml);  
    13.     var toastNotifier = ToastNotificationManager.CreateToastNotifier();  
    14.     toastNotifier.Show(toast);  
    15. }  
  • Adaptive and Interactive toast

    Create flexible toast notifications with more content and optional inline images without being limited to the previous “toast template catalog”.

    Create interactive toast notifications, which enables user interaction.

XML

  1. <toast launch="app-defined-string">  
  2.     <visual>  
  3.         <binding template="ToastGeneric"> <text>Sample</text> <text>This is a simple toast notification example</text>  
  4.             <image placement="AppLogoOverride" src="oneAlarm.png" /> </binding>  
  5.     </visual>  
  6.     <actions>  
  7.         <action content="check" arguments="check" imageUri="check.png" />  
  8.         <action content="cancel" arguments="cancel" /> </actions> <audio src="ms-winsoundevent:Notification.Reminder" />   
  9. </toast>  
<visual>: Content available for the users to visually see, including the text and images.
<actions>: Buttons/inputs the developer wants to add inside the notification.
<audio>: The sound played, when the notification pops.

output

output

New Functionalities

 

  1. Expanding the toasts on the mobile.
  2. More types of activations through actions.
  3. No more ToastCapable : Now, there is no need to declare the capability of whether app is toast capable or not.
  4. Toasts and Tiles can now get in Synchronization : In Windows 10, we added the ability for an app to be notified, when the app’s collection of the notifications is changed in any way and is not caused by the app’s local client.
  5. New Notification Setting behaviour : In Windows 10, only after an app sends a first toast notification, it will be added to the Notifications & Actions section of System Settings, from which the user can disable or enable the toast notifications for your app at any time.

Interactive toast

Various activation types can be set.

  1. Activation type=foreground
    Tap button>app launches>retrieve args>take actions.
  2. Activation type =background
    Tap>Task launches>retrieve args>Take actions.
  3. Activation type = protocol
    Tap>Protocol activates>Web/app(as per uri match).
  4. Activation type = system
    Tap>system handles(reminder/alarm).

Special Toast Scenarios: scenario="senario name".

  • Alarm
  • Reminder
  • Incomming call

Notification Types

  1. Tile
  2. Badge
  3. Toast
  4. Raw(background Task)

WNS

  • One Service across all the devices.
  • One process to register an app for push.
  • One tile template to push to Windows & phone apps.
  • Request Channel URL>Register with your Cloud Service >Authenticate & Push notification.
    References : PushTestServer and Sample Code.

Developers Can do,

  • Remove one or many notifications.
  • Tag and group the notifications.
  • Replace a notification with a new one.
  • Set an expiration on the notifications.
  • Send "Ghost Toast" notifications (only show up in notification center).