,

Power Management and Push Notification

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).

Image

FIGURE 15.3 Device power states transition from a normal power level to low and to critically low.

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:

Image NormalPowerLevelThe battery is not low. All push notification types are sent to the device.

Image LowPowerLevelThe battery is low. Only raw notifications are sent to the device.

Image CriticalLowPowerLevelThe battery is critically low. No push notifications of any type are sent to the device.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.96.26