Capacitor plugin to enable background mode
This plugin replace to capacitor-plugin-background-mode
npm install @anuradev/capacitor-background-mode
npx cap sync
enable()
disable()
getSettings()
setSettings(...)
checkForegroundPermission()
requestForegroundPermission()
checkNotificationsPermission()
requestNotificationsPermission()
checkBatteryOptimizations()
requestDisableBatteryOptimizations()
enableWebViewOptimizations()
disableWebViewOptimizations()
moveToBackground()
moveToForeground()
isScreenOff()
isEnabled()
isActive()
wakeUp()
unlock()
addListener('appInBackground', ...)
addListener('appInForeground', ...)
removeAllListeners()
- Interfaces
- Type Aliases
enable() => Promise<void>
disable() => Promise<void>
getSettings() => Promise<{ settings: ISettings; }>
Returns: Promise<{ settings: ISettings; }>
setSettings(settings: Partial<ISettings>) => Promise<void>
Param | Type |
---|---|
settings |
Partial<ISettings> |
checkForegroundPermission() => Promise<PermissionStatus>
Returns: Promise<PermissionStatus>
requestForegroundPermission() => Promise<PermissionStatus>
Returns: Promise<PermissionStatus>
checkNotificationsPermission() => Promise<PermissionStatus>
Returns: Promise<PermissionStatus>
requestNotificationsPermission() => Promise<PermissionStatus>
Returns: Promise<PermissionStatus>
checkBatteryOptimizations() => Promise<{ disabled: boolean; }>
Returns: Promise<{ disabled: boolean; }>
requestDisableBatteryOptimizations() => Promise<{ disabled: boolean; }>
Returns: Promise<{ disabled: boolean; }>
enableWebViewOptimizations() => Promise<void>
disableWebViewOptimizations() => Promise<void>
moveToBackground() => Promise<void>
moveToForeground() => Promise<void>
isScreenOff() => Promise<{ isScreenOff: boolean; }>
Returns: Promise<{ isScreenOff: boolean; }>
isEnabled() => Promise<{ enabled: boolean; }>
Returns: Promise<{ enabled: boolean; }>
isActive() => Promise<{ activated: boolean; }>
Returns: Promise<{ activated: boolean; }>
wakeUp() => Promise<void>
unlock() => Promise<void>
addListener(eventName: 'appInBackground', listenerFunc: () => void) => Promise<PluginListenerHandle> & PluginListenerHandle
Param | Type |
---|---|
eventName |
'appInBackground' |
listenerFunc |
() => void |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
addListener(eventName: 'appInForeground', listenerFunc: () => void) => Promise<PluginListenerHandle> & PluginListenerHandle
Param | Type |
---|---|
eventName |
'appInForeground' |
listenerFunc |
() => void |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
removeAllListeners() => Promise<void>
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' |
Prop | Type |
---|---|
display |
PermissionState |
Prop | Type |
---|---|
remove |
() => Promise<void> |
Make all properties in T optional
{
[P in keyof T]?: T[P];
}
'prompt' | 'prompt-with-rationale' | 'granted' | 'denied'