Even though push notification assists in reducing the power consumption of the phone, maintaining any kind of network connection unfortunately expends more power than most other device functions. Therefore, when the phone’s battery level is low, to help reduce power consumption, the phone progressively prevents certain types of notifications from being received by the device (see Figure 15.3).
When an HttpNotificationChannel
raises its ErrorOccured
event with an ErrorType
value of PowerLevelChanged
, it indicates that there is a change to the types of notifications that are to be delivered to the device.
The NotificationChannelErrorEventArgs.ErrorAdditionalData
property can be used to obtain the ChannelPowerLevel
enum value, as shown in the following excerpt:
void HandleChannelErrorOccurred(
object sender, NotificationChannelErrorEventArgs e)
{
switch (e.ErrorType)
{
case ChannelErrorType.PowerLevelChanged:
if (e.ErrorAdditionalData == (int)ChannelPowerLevel.LowPowerLevel
|| e.ErrorAdditionalData
== (int)ChannelPowerLevel.CriticalLowPowerLevel)
{
/* Power level is too low. */
}
break;
}
}
The following list describes each of the ChannelPowerLevel
enum values:
NormalPowerLevel—The battery is not low. All push notification types are sent to the device.
LowPowerLevel—The battery is low. Only raw notifications are sent to the device.
CriticalLowPowerLevel—The battery is critically low. No push notifications of any type are sent to the device.
18.117.96.26