0

I'm trying to develop a cross platform application using Angular+Nativescript. I need to capture the battery percentage of a mobile device when it is attempted to be switched off.

I have obtained the nativescript plugin to capture the battery levels. But I need to know in which event will I be able to capture the mobile switching off action and store the battery level before it happens.

Any help is greatly appreciated!

Ranjani
  • 73
  • 1
  • 10

1 Answers1

1

This is not possible on iOS.

On Android you can achieve this by listening to the android.intent.action.ACTION_SHUTDOWN and android.intent.action.QUICKBOOT_POWEROFF events. Many questions have already been asked about this subject, so I would recommend you have a look at other questions to learn more about these events.

You can find information about how to register a BroadcastReceiver using NativeScript here.

Dexter
  • 2,462
  • 4
  • 24
  • 28