Pubnub push notifications and battery life on Android

We are writing a chat application and have a Pubnub service running in the background, listening to messages and running the notification intent upon receipt. The problem is that we use a partial lock after the phone sleeps, and it just kills the battery (the application takes up> 20% of the battery).

Is there a less intensive way to listen to messages? I also tried looking back at the Pubnub Push notification code examples on Android, but didn't find them.

Thanks, Saswat

+6
source share
2 answers

According to this site :

COMING SOON: GCM push alerts are in beta and will be released in early June.

But on this website date it says:

PubNub Support published this July 19, 2012 19:59

So, to answer your question: at the moment there is no more intensive way to listen to messages than when using tracking lock. in fact, PubNub specifically states that you must use partial trail blocking on this website above.

There is also no documentation for Android PubNub github . They claim that PubNub is better than Google C2DM. Google C2DM was deprecated many years ago.

+1
source

The PubNubs Android SDK background process has been optimized through many iterations. Our tests show almost no difference in battery discharge between partial blocking of tracking, doing nothing, and the PWL + PubNub socket.

Even measuring the most energy-intensive use case, which is a 4G connection, weve compared for 4 hours on a Nexus 4, the difference between standby lock and PWL + PubNub is 4% of the difference in battery for 4 hours, while the device receives a 1k message every 5 minutes. In Wi-Fi, the difference is much smaller.

While GCM has many minutes of socket timeouts ( per thread ,) PubNub is always reliable. However, you can configure PubNub to disable PWL for applications where real-time is not always required, but reliable. In our opinion, this customization makes PubNub the most convenient option for developers for energy-efficient socket communications .

If you still see a noticeable battery drain, refer to support@pubnub.com with a copy of the appropriate code so that we can help debug and report best practices.

Hooray!

+5
source

All Articles