News for hackers. Stuff that matters.
Re:Your battery status may be used to track you online by vmateixeira on Tuesday August 02, 2016 @10:59AM (#12210418)
...warn the user that the app needs to shut down to avoid data loss..

Doesn't the client (laptop, phone, etc) does this already?

Re:Your battery status may be used to track you online by DougWebb on Tuesday August 02, 2016 @03:42PM (#12212721)
I've seen my devices give notifications about the battery level to me, but I don't think they notify the apps I'm running, and if I ignore the notifications until the battery dies the device just shuts down. The apps have no chance to save their state.

Often, that's probably just fine. But if I'm developing an app and I have a requirement to save state before my app gets shut down due to power failure, this api will allow me to do that. It's the equivalent to a drive flushing any writes before shutting down; normally they'd get flushed sooner or later, but if you have to shut down NOW, you'd better flush now too while you can.

Re:Your battery status may be used to track you online by vmateixeira on Wednesday August 03, 2016 @04:05AM (#12216398)
I mean, but if the device notifies you that it's running low on battery... maybe you should close the app? Shouldn't this be enough?

You would avoid loosing data, and regarding user experience, also avoid a slower performance of your app (and perhaps complaining about it?), and also seeing your device shutting down itself with your app screen running in background (which is pretty lame).

Re:Your battery status may be used to track you online by DougWebb on Wednesday August 03, 2016 @12:31PM (#12219199)
As a user, maybe that should be enough. Maybe not. It depends on the app and how critical the data/state is, I guess.

As a developer, trying to implement requirements set by a product designer/owner who thinks saving the data is critical even if the user doesn't cooperate, the api is useful to have.

Re:Your battery status may be used to track you online by vmateixeira on Thursday August 04, 2016 @06:07AM (#12224509)
Maybe a critical app shouldn't be web based?

If you're really worried about your battery running low and working with critical data, removing the browser overhead which is draining you battery should be one of the first things to do.