When a channel error occurs, the NotificationChannelErrorEventArgs.ErrorType
property can be used to determine the nature of the error, as the following excerpt demonstrates:
void HandleChannelErrorOccurred(
object sender, NotificationChannelErrorEventArgs e)
{
switch (e.ErrorType)
{
case ChannelErrorType.ChannelOpenFailed:
// ...
break;
case ChannelErrorType.MessageBadContent:
// ...
break;
case ChannelErrorType.NotificationRateTooHigh:
// ...
break;
case ChannelErrorType.PayloadFormatError:
// ...
break;
case ChannelErrorType.PowerLevelChanged:
// ...
break;
}
}
The following list describes the NotificationChannelErrorEventArgs.ErrorType
enumeration values:
ChannelOpenFailed—Occurs when the push client is unable to establish a connection with the MPNS. Note that exceptions resulting from, for example, a channel already being open, are raised at the call to the HttpNotificationChannel.Open
method.
MessageBadContent—Occurs when using tile notifications and the BackgroundImage
URI is pointing to a remote image, despite the HttpNotificationChannel
not being bound to a list of URIs. Tile notifications are discussed later in the chapter.
NotificationRateTooHigh—Occurs when the push notification client is unable to receive messages because the cloud service is sending too many messages at too high a rate.
PayloadFormatError—Occurs when the XML payload format, or the HTTP header of the push notification, is syntactically invalid. When this error occurs, the HttpNotificationChannel
is closed and the channel must be reopened.
PowerLevelChanged—Occurs when the device’s battery level changes significantly enough to trigger a change in the push client’s power policy. This topic is discussed in the next section “Power Management and Push Notification.”
Additional error information can be obtained by examining the NotificationChannelErrorEventArgs.ErrorCode
property, which identifies the HRESULT
of the Exception
. The HRESULT
is a coded numerical value that is assigned to some specific exceptions.
18.222.232.128