1.0.1 • Published 1 year ago

android-battery-optimization v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

android-battery-optimization

This plugin is designed to provide easy access to Android battery settings and to make the app work minimized.

Install

npm install android-battery-optimization
npx cap sync

API

moveToForeground()

moveToForeground() => Promise<void>

Moves the app to the foreground.

On Android SDK 23+, the user must grant the manage overlay permission. You can use the requestManageOverlayPermission() method to request the permission and the checkManageOverlayPermission() method to check if the permission is granted.

Only available on Android.

Since: 0.3.0


startForegroundService(...)

startForegroundService(options: StartForegroundServiceOptions) => Promise<void>

Starts the foreground service.

Only available on Android.

ParamType
optionsStartForegroundServiceOptions

Since: 0.0.1


disableWebViewOptimizations()

disableWebViewOptimizations() => Promise<void>

Stops the foreground service.

Only available on Android.

Since: 0.0.1


stopForegroundService()

stopForegroundService() => Promise<void>

disables web view optimizations.

Only available on Android.

Since: 0.0.1


checkPermissions()

checkPermissions() => Promise<PermissionStatus>

Check permission to display notifications.

On Android, this method only needs to be called on Android 13+.

Only available on Android.

Returns: Promise<PermissionStatus>

Since: 5.0.0


requestPermissions()

requestPermissions() => Promise<PermissionStatus>

Request permission to display notifications.

On Android, this method only needs to be called on Android 13+.

Only available on Android.

Returns: Promise<PermissionStatus>

Since: 5.0.0


checkManageOverlayPermission()

checkManageOverlayPermission() => Promise<ManageOverlayPermissionResult>

Check if the overlay permission is granted.

Only available on Android.

Returns: Promise<ManageOverlayPermissionResult>

Since: 0.3.0


requestManageOverlayPermission()

requestManageOverlayPermission() => Promise<ManageOverlayPermissionResult>

Request the manage overlay permission.

Only available on Android.

Returns: Promise<ManageOverlayPermissionResult>

Since: 0.3.0


addListener('buttonClicked', ...)

addListener(eventName: 'buttonClicked', listenerFunc: ButtonClickedEventListener) => Promise<PluginListenerHandle>

Called when a notification button is clicked.

Only available on iOS.

ParamType
eventName'buttonClicked'
listenerFuncButtonClickedEventListener

Returns: Promise<PluginListenerHandle>

Since: 0.2.0


removeAllListeners()

removeAllListeners() => Promise<void>

Remove all listeners for this plugin.

Since: 0.2.0


Interfaces

StartForegroundServiceOptions

PropTypeDescriptionSince
bodystringThe body of the notification, shown below the title.0.0.1
buttonsNotificationButton[]The buttons to show on the notification. Only available on Android (SDK 24+).0.2.0
idnumberThe notification identifier.0.0.1
smallIconstringThe status bar icon for the notification. Icons should be placed in your app's res/drawable folder. The value for this option should be the drawable resource ID, which is the filename without an extension.0.0.1
titlestringThe title of the notification.0.0.1

NotificationButton

PropTypeDescriptionSince
titlestringThe button title.0.2.0
idnumberThe button identifier. This is used to identify the button when the buttonClicked event is emitted.0.2.0

PermissionStatus

PropTypeDescriptionSince
displayPermissionStatePermission state of displaying notifications.5.0.0

ManageOverlayPermissionResult

PropTypeDescriptionSince
grantedbooleanWhether the permission is granted. This is always true on Android SDK < 23.0.3.0

PluginListenerHandle

PropType
remove() => Promise<void>

ButtonClickedEvent

PropTypeDescriptionSince
buttonIdnumberThe button identifier.0.2.0

Type Aliases

PermissionState

'prompt' | 'prompt-with-rationale' | 'granted' | 'denied'

ButtonClickedEventListener

(event: ButtonClickedEvent): void

1.0.1

1 year ago

1.0.0

1 year ago