Settings

Every request to the WNS (except the Authentication) needs custom header values.

With Windows Notification, the header needs to be set in WNSNotificationOptions object.

This object contains all the WNS header request fields and when the Windows Notification object perform a request to the WNS, it use the NotificationOptions object to get the header values (NOTE: It doesn't pass header fields with None or null value).

NOTE: X-WNS-Match require that the HTTP verb for request is DELETE, so you need to pass it when you perform the notification.

This is an example of how WNSNotificationOptions object works:

$Options = new WindowsNotification\WNSNotificationOptions();    $Options->SetX_WNS_REQUESTFORSTATUS(WindowsNotification\X_WNS_RequestForStatus::Request);
$Options->SetContentType(WindowsNotification\Content_Type::Standard);
$Options->SetX_WNS_TYPE(WindowsNotification\X_WNS_Type::Toast);

And after you need to set the option to the WindowsNotificationClass object with:

The constructor

$Notifier = new WindowsNotification\WindowsNotificationClass($Options);

 

Or the method

$Notifier->SetOptions($Options);
 

For the full list of header request you can check this link, every custom header have an attribute to set in options.

NOTE: It’s your responsibility to set the right header values, the default values are for Toast

Enumerations 

How you can see, every header (except content length that it is not exposed) have an attribute in settings.

Some attributes, like X-WNS-TAG can have whatever type of value, others like Content-Type or X-WNS-Type need a specified value.

The WindowsNotification namespace has various classes to help you to set the right values in Options fields.

These classes are used like enumeration, so if you need to pass value for SetX_WNS_Type (X-WNS-Type header value) you can use the X_WNS_Type class, that’s defined this way:

/**
     * WNS headers option for notification type
     * NOTE: REQUIRED FIELD
     * @see https://msdn.microsoft.com/en-us/library/windows/apps/hh465435.aspx#pncodes_x_wns_type
     */  
final class X_WNS_Type  
{     
const __default = self::Toast;
    const Toast = "wns/toast";     
const Badge = "wns/badge";
    const Raw = "wns/raw";
    const Tile = "wns/tile";     
const None = null
}
 

This is just an example, in the same way you have enums for RequestForSatuts, cache policy etc.

Last edited Jun 20, 2015 at 11:12 AM by Andreabbondanza, version 16