Templates

Toast and Badge notifications have a class helpers with Templates (Tile support does not exists for now, the reason is the high number of templates, the versions and their combinations).

Raw is raw, can’t have a template :)

Badge

In first place, check this link for the devices support (Windows\Windows phone 8.1).

The TemplateBadge class exposes a set of defaults constants xml templates for badge

const NoBadge = '<?xml version="1.0" encoding="utf-8"?><badge value="none"/>';
const Activity = '<?xml version="1.0" encoding="utf-8"?><badge value="activity"/>';
const Alarm = '<?xml version="1.0" encoding="utf-8"?><badge value="alarm"/>';
const Alert = '<?xml version="1.0" encoding="utf-8"?><badge value="alert"/>';
const Attention = '<?xml version="1.0" encoding="utf-8"?><badge value="attention"/>';
const Available = '<?xml version="1.0" encoding="utf-8"?><badge value="available"/>';
const Away = '<?xml version="1.0" encoding="utf-8"?><badge value="away"/>';
const Busy = '<?xml version="1.0" encoding="utf-8"?><badge value="busy"/>';
const Error = '<?xml version="1.0" encoding="utf-8"?><badge value="error"/>';
const NewMessage = '<?xml version="1.0" encoding="utf-8"?><badge value="newMessage"/>';
const Paused = '<?xml version="1.0" encoding="utf-8"?><badge value="paused"/>';
const Playing = '<?xml version="1.0" encoding="utf-8"?><badge value="playing"/>';
const Unavailable = '<?xml version="1.0" encoding="utf-8"?><badge value="unavailable"/>';

And a method for the numeric badge xml template

public static function NumericBadge($val)

NOTE: The $val must be >= 0, otherwise the method returns numeric template for 0, and if $val > 100, Windows set default badge to 99+.

Toast

Like before, check the catalog for devices support.

The TemplateToast expose the follow constants for sounds

const Silent = '<audio silent="true" />';
const NotificationDefault = '<audio src="ms-winsoundevent:Notification.Default" loop="false" />';
const NotificationIM = '<audio src="ms-winsoundevent:Notification.IM" loop="false" />';
const NotificationMail = '<audio src="ms-winsoundevent:Notification.Mail" loop="false" />';
const NotificationReminder = '<audio src="ms-winsoundevent:Notification.Reminder" loop="false" />';
const NotificationSms = '<audio src="ms-winsoundevent:Notification.SMS" loop="false" />';
const NotificationLoopingAlarm = '<audio src="ms-winsoundevent:Notification.Looping.Alarm" loop="true" />';
const NotificationLoopingAlarm2 = '<audio src="ms-winsoundevent:Notification.Looping.Alarm2" loop="true" />';
const NotificationLoopingAlarm3 = '<audio src="ms-winsoundevent:Notification.Looping.Alarm3" loop="true" />';
const NotificationLoopingAlarm4 = '<audio src="ms-winsoundevent:Notification.Looping.Alarm4" loop="true" />';
const NotificationLoopingAlarm5 = '<audio src="ms-winsoundevent:Notification.Looping.Alarm5" loop="true" />';
const NotificationLoopingAlarm6 = '<audio src="ms-winsoundevent:Notification.Looping.Alarm6" loop="true" />';
const NotificationLoopingAlarm7 = '<audio src="ms-winsoundevent:Notification.Looping.Alarm7" loop="true" />';
const NotificationLoopingAlarm8 = '<audio src="ms-winsoundevent:Notification.Looping.Alarm8" loop="true" />';
const NotificationLoopingAlarm9 = '<audio src="ms-winsoundevent:Notification.Looping.Alarm9" loop="true" />';
const NotificationLoopingAlarm10 = '<audio src="ms-winsoundevent:Notification.Looping.Alarm10" loop="true" />';
const NotificationLoopingCall = '<audio src="ms-winsoundevent:Notification.Looping.Call" loop="true" />';
const NotificationLoopingCall2 = '<audio src="ms-winsoundevent:Notification.Looping.Call2" loop="true" />';
const NotificationLoopingCall3 = '<audio src="ms-winsoundevent:Notification.Looping.Call3" loop="true" />';
const NotificationLoopingCall4 = '<audio src="ms-winsoundevent:Notification.Looping.Call4" loop="true" />';
const NotificationLoopingCall5 = '<audio src="ms-winsoundevent:Notification.Looping.Call5" loop="true" />';
const NotificationLoopingCall6 = '<audio src="ms-winsoundevent:Notification.Looping.Call6" loop="true" />';
const NotificationLoopingCall7 = '<audio src="ms-winsoundevent:Notification.Looping.Call7" loop="true" />';
const NotificationLoopingCall8 = '<audio src="ms-winsoundevent:Notification.Looping.Call8" loop="true" />';
const NotificationLoopingCall9 = '<audio src="ms-winsoundevent:Notification.Looping.Call9" loop="true" />';
const NotificationLoopingCall10 = '<audio src="ms-winsoundevent:Notification.Looping.Call10" loop="true" />';

For sounds we have a method called

public static function CustomSound($url,$loop = false)

Where you can pass the local audio source and the loop.

NOTE: Only Windows Phone 8.1 allows the use of a local audio resource in addition to the toast audio options discussed here.

The other exposed class methods are for the ToastNotification template.

public static function ToastText01($bodyText, $sound = TemplateToast::NotificationDefault)
public static function ToastText02($headLineText,$bodyText, $sound = TemplateToast::NotificationDefault)
public static function ToastText03($headLineText,$bodyText, $sound = TemplateToast::NotificationDefault)
public static function ToastText04($headLineText,$bodyText1,$bodyText2, $sound = TemplateToast::NotificationDefault)
public static function ToastImageAndText01($bodyText,$src, $alt = "", $sound = TemplateToast::NotificationDefault)
public static function ToastImageAndText02($headLineText,$bodyText,$src, $alt="", $sound = TemplateToast::NotificationDefault)
public static function ToastImageAndText03($headLineText,$bodyText,$src,$alt = "", $sound = TemplateToast::NotificationDefault)
public static function ToastImageAndText04($headLineText,$bodyText1,$bodyText2,$src,$alt = "", $sound = TemplateToast::NotificationDefault)

How you can see, every method is an equivalent of a template in the catalog.

NOTE: The sound is always set to default notification sound

Last edited May 16, 2015 at 3:25 PM by Andreabbondanza, version 16