@anuradev/capacitor-background-mode
v7.2.1
Published
Capacitor plugin to enable background mode
Readme
@anuradev/capacitor-background-mode
Capacitor plugin to enable background mode
This plugin replace to capacitor-plugin-background-mode
Install
npm install @anuradev/capacitor-background-mode
npx cap syncAPI
enable(...)disable()updateNotification(...)checkNotificationsPermission()requestNotificationsPermission()checkMicrophonePermission()requestMicrophonePermission()checkBatteryOptimizations()requestDisableBatteryOptimizations()enableWebViewOptimizations()disableWebViewOptimizations()moveToBackground()moveToForeground()isScreenOff()isEnabled()isActive()wakeUp()unlock()addListener('appInBackground', ...)addListener('appInForeground', ...)removeAllListeners()- Interfaces
- Type Aliases
enable(...)
enable(settings: Partial<ISettings>) => Promise<void>| Param | Type |
| -------------- | ------------------------------------------------------------------------------------- |
| settings | Partial<ISettings> |
disable()
disable() => Promise<void>updateNotification(...)
updateNotification(settings: Partial<ISettings>) => Promise<void>| Param | Type |
| -------------- | ------------------------------------------------------------------------------------- |
| settings | Partial<ISettings> |
checkNotificationsPermission()
checkNotificationsPermission() => Promise<NotificationPermissionStatus>Returns: Promise<NotificationPermissionStatus>
requestNotificationsPermission()
requestNotificationsPermission() => Promise<NotificationPermissionStatus>Returns: Promise<NotificationPermissionStatus>
checkMicrophonePermission()
checkMicrophonePermission() => Promise<MicrophonePermissionStatus>Returns: Promise<MicrophonePermissionStatus>
requestMicrophonePermission()
requestMicrophonePermission() => Promise<MicrophonePermissionStatus>Returns: Promise<MicrophonePermissionStatus>
checkBatteryOptimizations()
checkBatteryOptimizations() => Promise<{ enabled: boolean; }>Returns: Promise<{ enabled: boolean; }>
requestDisableBatteryOptimizations()
requestDisableBatteryOptimizations() => Promise<{ enabled: boolean; }>Returns: Promise<{ enabled: boolean; }>
enableWebViewOptimizations()
enableWebViewOptimizations() => Promise<void>disableWebViewOptimizations()
disableWebViewOptimizations() => Promise<void>moveToBackground()
moveToBackground() => Promise<void>moveToForeground()
moveToForeground() => Promise<void>isScreenOff()
isScreenOff() => Promise<{ isScreenOff: boolean; }>Returns: Promise<{ isScreenOff: boolean; }>
isEnabled()
isEnabled() => Promise<{ enabled: boolean; }>Returns: Promise<{ enabled: boolean; }>
isActive()
isActive() => Promise<{ activated: boolean; }>Returns: Promise<{ activated: boolean; }>
wakeUp()
wakeUp() => Promise<void>unlock()
unlock() => Promise<void>addListener('appInBackground', ...)
addListener(eventName: 'appInBackground', listenerFunc: () => void) => Promise<PluginListenerHandle>| Param | Type |
| ------------------ | ------------------------------ |
| eventName | 'appInBackground' |
| listenerFunc | () => void |
Returns: Promise<PluginListenerHandle>
addListener('appInForeground', ...)
addListener(eventName: 'appInForeground', listenerFunc: () => void) => Promise<PluginListenerHandle>| Param | Type |
| ------------------ | ------------------------------ |
| eventName | 'appInForeground' |
| listenerFunc | () => void |
Returns: Promise<PluginListenerHandle>
removeAllListeners()
removeAllListeners() => Promise<void>Interfaces
ISettings
| Prop | Type |
| -------------------------------- | ---------------------------------------------- |
| title | string |
| text | string |
| subText | string |
| bigText | boolean |
| resume | boolean |
| silent | boolean |
| hidden | boolean |
| color | string |
| icon | string |
| channelName | string |
| channelDescription | string |
| allowClose | boolean |
| closeIcon | string |
| closeTitle | string |
| showWhen | boolean |
| disableWebViewOptimization | boolean |
| visibility | 'public' | 'private' | 'secret' |
NotificationPermissionStatus
| Prop | Type |
| ------------------- | ----------------------------------------------------------- |
| notifications | PermissionState |
MicrophonePermissionStatus
| Prop | Type |
| ---------------- | ----------------------------------------------------------- |
| microphone | PermissionState |
PluginListenerHandle
| Prop | Type |
| ------------ | ----------------------------------------- |
| remove | () => Promise<void> |
Type Aliases
Partial
Make all properties in T optional
{ [P in keyof T]?: T[P]; }
PermissionState
'prompt' | 'prompt-with-rationale' | 'granted' | 'denied'
