UNPKG

@capawesome-team/capacitor-android-foreground-service

Version:

Capacitor plugin to run a foreground service on Android.

839 lines 21.8 kB
{ "api": { "name": "ForegroundServicePlugin", "slug": "foregroundserviceplugin", "docs": "", "tags": [], "methods": [ { "name": "moveToForeground", "signature": "() => Promise<void>", "parameters": [], "returns": "Promise<void>", "tags": [ { "name": "since", "text": "0.3.0" }, { "name": "experimental", "text": "This method is experimental and may not work as expected." } ], "docs": "Moves the app to the foreground.\n\nOn Android SDK 23+, the user must grant the manage overlay permission.\nYou can use the `requestManageOverlayPermission()` method to request the\npermission and the `checkManageOverlayPermission()` method to check if the\npermission is granted.\n\nOnly available on Android.", "complexTypes": [], "slug": "movetoforeground" }, { "name": "startForegroundService", "signature": "(options: StartForegroundServiceOptions) => Promise<void>", "parameters": [ { "name": "options", "docs": "", "type": "StartForegroundServiceOptions" } ], "returns": "Promise<void>", "tags": [ { "name": "since", "text": "0.0.1" } ], "docs": "Starts the foreground service.\n\nOnly available on Android.", "complexTypes": [ "StartForegroundServiceOptions" ], "slug": "startforegroundservice" }, { "name": "updateForegroundService", "signature": "(options: UpdateForegroundServiceOptions) => Promise<void>", "parameters": [ { "name": "options", "docs": "", "type": "StartForegroundServiceOptions" } ], "returns": "Promise<void>", "tags": [ { "name": "since", "text": "6.1.0" } ], "docs": "Updates the notification details of the running foreground service.\n\nOnly available on Android.", "complexTypes": [ "UpdateForegroundServiceOptions" ], "slug": "updateforegroundservice" }, { "name": "stopForegroundService", "signature": "() => Promise<void>", "parameters": [], "returns": "Promise<void>", "tags": [ { "name": "since", "text": "0.0.1" } ], "docs": "Stops the foreground service.\n\nOnly available on Android.", "complexTypes": [], "slug": "stopforegroundservice" }, { "name": "checkPermissions", "signature": "() => Promise<PermissionStatus>", "parameters": [], "returns": "Promise<PermissionStatus>", "tags": [ { "name": "since", "text": "5.0.0" } ], "docs": "Check permission to display notifications.\n\nOn **Android**, this method only needs to be called on Android 13+.\n\nOnly available on Android.", "complexTypes": [ "PermissionStatus" ], "slug": "checkpermissions" }, { "name": "requestPermissions", "signature": "() => Promise<PermissionStatus>", "parameters": [], "returns": "Promise<PermissionStatus>", "tags": [ { "name": "since", "text": "5.0.0" } ], "docs": "Request permission to display notifications.\n\nOn **Android**, this method only needs to be called on Android 13+.\n\nOnly available on Android.", "complexTypes": [ "PermissionStatus" ], "slug": "requestpermissions" }, { "name": "checkManageOverlayPermission", "signature": "() => Promise<ManageOverlayPermissionResult>", "parameters": [], "returns": "Promise<ManageOverlayPermissionResult>", "tags": [ { "name": "since", "text": "0.3.0" } ], "docs": "Check if the overlay permission is granted.\n\nOnly available on Android.", "complexTypes": [ "ManageOverlayPermissionResult" ], "slug": "checkmanageoverlaypermission" }, { "name": "requestManageOverlayPermission", "signature": "() => Promise<ManageOverlayPermissionResult>", "parameters": [], "returns": "Promise<ManageOverlayPermissionResult>", "tags": [ { "name": "since", "text": "0.3.0" } ], "docs": "Request the manage overlay permission.\n\nOnly available on Android.", "complexTypes": [ "ManageOverlayPermissionResult" ], "slug": "requestmanageoverlaypermission" }, { "name": "createNotificationChannel", "signature": "(options: CreateNotificationChannelOptions) => Promise<void>", "parameters": [ { "name": "options", "docs": "", "type": "CreateNotificationChannelOptions" } ], "returns": "Promise<void>", "tags": [ { "name": "since", "text": "6.1.0" } ], "docs": "Create a notification channel.\nIf not invoked, the plugin creates a channel with name and description set to \"Default\".\n\nOnly available for Android (SDK 26+).", "complexTypes": [ "CreateNotificationChannelOptions" ], "slug": "createnotificationchannel" }, { "name": "deleteNotificationChannel", "signature": "(options: DeleteNotificationChannelOptions) => Promise<void>", "parameters": [ { "name": "options", "docs": "", "type": "DeleteNotificationChannelOptions" } ], "returns": "Promise<void>", "tags": [ { "name": "since", "text": "6.1.0" } ], "docs": "Delete a notification channel.\n\nOnly available for Android (SDK 26+).", "complexTypes": [ "DeleteNotificationChannelOptions" ], "slug": "deletenotificationchannel" }, { "name": "addListener", "signature": "(eventName: 'buttonClicked', listenerFunc: ButtonClickedEventListener) => Promise<PluginListenerHandle>", "parameters": [ { "name": "eventName", "docs": "", "type": "'buttonClicked'" }, { "name": "listenerFunc", "docs": "", "type": "ButtonClickedEventListener" } ], "returns": "Promise<PluginListenerHandle>", "tags": [ { "name": "since", "text": "0.2.0" } ], "docs": "Called when a notification button is clicked.\n\nOnly available on iOS.", "complexTypes": [ "PluginListenerHandle", "ButtonClickedEventListener" ], "slug": "addlistenerbuttonclicked-" }, { "name": "addListener", "signature": "(eventName: 'notificationTapped', listenerFunc: NotificationTappedEventListener) => Promise<PluginListenerHandle>", "parameters": [ { "name": "eventName", "docs": "", "type": "'notificationTapped'" }, { "name": "listenerFunc", "docs": "", "type": "NotificationTappedEventListener" } ], "returns": "Promise<PluginListenerHandle>", "tags": [ { "name": "since", "text": "8.1.0" } ], "docs": "Called when the foreground service notification is tapped.\n\nOnly available on Android.", "complexTypes": [ "PluginListenerHandle", "NotificationTappedEventListener" ], "slug": "addlistenernotificationtapped-" }, { "name": "removeAllListeners", "signature": "() => Promise<void>", "parameters": [], "returns": "Promise<void>", "tags": [ { "name": "since", "text": "0.2.0" } ], "docs": "Remove all listeners for this plugin.", "complexTypes": [], "slug": "removealllisteners" } ], "properties": [] }, "interfaces": [ { "name": "StartForegroundServiceOptions", "slug": "startforegroundserviceoptions", "docs": "", "tags": [], "methods": [], "properties": [ { "name": "body", "tags": [ { "text": "0.0.1", "name": "since" }, { "text": "\"This is the body of the notification\"", "name": "example" } ], "docs": "The body of the notification, shown below the title.", "complexTypes": [], "type": "string" }, { "name": "buttons", "tags": [ { "text": "0.2.0", "name": "since" } ], "docs": "The buttons to show on the notification.\n\nOnly available on Android (SDK 24+).", "complexTypes": [ "NotificationButton" ], "type": "NotificationButton[] | undefined" }, { "name": "id", "tags": [ { "text": "0.0.1", "name": "since" }, { "text": "123", "name": "example" } ], "docs": "The notification identifier.", "complexTypes": [], "type": "number" }, { "name": "serviceType", "tags": [ { "text": "6.2.0", "name": "since" }, { "text": "https ://developer.android.com/develop/background-work/services/fgs/service-types", "name": "see" } ], "docs": "The foreground service type.\n\nOnly available on Android (SDK 29+).", "complexTypes": [ "ServiceType" ], "type": "ServiceType" }, { "name": "smallIcon", "tags": [ { "text": "0.0.1", "name": "since" }, { "text": "\"ic_stat_icon_config_sample\"", "name": "example" } ], "docs": "The status bar icon for the notification.\n\nIcons should be placed in your app's `res/drawable` folder. The value for\nthis option should be the drawable resource ID, which is the filename\nwithout an extension.", "complexTypes": [], "type": "string" }, { "name": "title", "tags": [ { "text": "0.0.1", "name": "since" }, { "text": "\"This is the title of the notification\"", "name": "example" } ], "docs": "The title of the notification.", "complexTypes": [], "type": "string" }, { "name": "silent", "tags": [ { "text": "6.1.0", "name": "since" }, { "text": "false", "name": "default" } ], "docs": "If true, will only alert (sound/vibration) on the first notification.\nSubsequent updates will be silent.", "complexTypes": [], "type": "boolean | undefined" }, { "name": "notificationChannelId", "tags": [ { "text": "6.1.0", "name": "since" } ], "docs": "The notification channel identifier.", "complexTypes": [], "type": "string | undefined" } ] }, { "name": "NotificationButton", "slug": "notificationbutton", "docs": "", "tags": [ { "text": "0.2.0", "name": "since" } ], "methods": [], "properties": [ { "name": "title", "tags": [ { "text": "0.2.0", "name": "since" }, { "text": "\"Stop\"", "name": "example" } ], "docs": "The button title.", "complexTypes": [], "type": "string" }, { "name": "id", "tags": [ { "text": "0.2.0", "name": "since" }, { "text": "123", "name": "example" } ], "docs": "The button identifier.\n\nThis is used to identify the button when\nthe `buttonClicked` event is emitted.", "complexTypes": [], "type": "number" } ] }, { "name": "PermissionStatus", "slug": "permissionstatus", "docs": "", "tags": [ { "text": "5.0.0", "name": "since" } ], "methods": [], "properties": [ { "name": "display", "tags": [ { "text": "5.0.0", "name": "since" } ], "docs": "Permission state of displaying notifications.", "complexTypes": [ "PermissionState" ], "type": "PermissionState" } ] }, { "name": "ManageOverlayPermissionResult", "slug": "manageoverlaypermissionresult", "docs": "", "tags": [ { "text": "0.3.0", "name": "since" } ], "methods": [], "properties": [ { "name": "granted", "tags": [ { "text": "0.3.0", "name": "since" }, { "text": "true", "name": "example" } ], "docs": "Whether the permission is granted.\n\nThis is always `true` on Android SDK < 23.", "complexTypes": [], "type": "boolean" } ] }, { "name": "CreateNotificationChannelOptions", "slug": "createnotificationchanneloptions", "docs": "", "tags": [ { "text": "6.1.0", "name": "since" } ], "methods": [], "properties": [ { "name": "description", "tags": [ { "text": "6.1.0", "name": "since" } ], "docs": "The description of this channel (presented to the user).", "complexTypes": [], "type": "string | undefined" }, { "name": "id", "tags": [ { "text": "6.1.0", "name": "since" } ], "docs": "The channel identifier.", "complexTypes": [], "type": "string" }, { "name": "importance", "tags": [ { "text": "6.1.0", "name": "since" } ], "docs": "The level of interruption for notifications posted to this channel.", "complexTypes": [ "Importance" ], "type": "Importance" }, { "name": "name", "tags": [ { "text": "6.1.0", "name": "since" } ], "docs": "The name of this channel (presented to the user).", "complexTypes": [], "type": "string" } ] }, { "name": "DeleteNotificationChannelOptions", "slug": "deletenotificationchanneloptions", "docs": "", "tags": [ { "text": "6.1.0", "name": "since" } ], "methods": [], "properties": [ { "name": "id", "tags": [ { "text": "6.1.0", "name": "since" } ], "docs": "The channel identifier.", "complexTypes": [], "type": "string" } ] }, { "name": "PluginListenerHandle", "slug": "pluginlistenerhandle", "docs": "", "tags": [], "methods": [], "properties": [ { "name": "remove", "tags": [], "docs": "", "complexTypes": [], "type": "() => Promise<void>" } ] }, { "name": "ButtonClickedEvent", "slug": "buttonclickedevent", "docs": "", "tags": [ { "text": "0.2.0", "name": "since" } ], "methods": [], "properties": [ { "name": "buttonId", "tags": [ { "text": "0.2.0", "name": "since" } ], "docs": "The button identifier.", "complexTypes": [], "type": "number" } ] }, { "name": "NotificationTappedEvent", "slug": "notificationtappedevent", "docs": "", "tags": [ { "text": "8.1.0", "name": "since" } ], "methods": [], "properties": [ { "name": "notificationId", "tags": [ { "text": "8.1.0", "name": "since" } ], "docs": "The notification identifier.", "complexTypes": [], "type": "number" } ] } ], "enums": [ { "name": "ServiceType", "slug": "servicetype", "members": [ { "name": "Location", "value": "8", "tags": [ { "text": "6.2.0", "name": "since" }, { "text": "https ://developer.android.com/develop/background-work/services/fgs/service-types#location", "name": "see" } ], "docs": "Long-running use cases that require location access, such as navigation and location sharing." }, { "name": "Microphone", "value": "128", "tags": [ { "text": "6.2.0", "name": "since" }, { "text": "https ://developer.android.com/develop/background-work/services/fgs/service-types#microphone", "name": "see" } ], "docs": "Continue microphone capture from the background, such as voice recorders or communication apps." } ] }, { "name": "Importance", "slug": "importance", "members": [ { "name": "Min", "value": "1", "tags": [ { "text": "6.1.0", "name": "since" } ], "docs": "" }, { "name": "Low", "value": "2", "tags": [ { "text": "6.1.0", "name": "since" } ], "docs": "" }, { "name": "Default", "value": "3", "tags": [ { "text": "6.1.0", "name": "since" } ], "docs": "" }, { "name": "High", "value": "4", "tags": [ { "text": "6.1.0", "name": "since" } ], "docs": "" }, { "name": "Max", "value": "5", "tags": [ { "text": "6.1.0", "name": "since" } ], "docs": "" } ] } ], "typeAliases": [ { "name": "UpdateForegroundServiceOptions", "slug": "updateforegroundserviceoptions", "docs": "", "types": [ { "text": "StartForegroundServiceOptions", "complexTypes": [ "StartForegroundServiceOptions" ] } ] }, { "name": "PermissionState", "slug": "permissionstate", "docs": "", "types": [ { "text": "'prompt'", "complexTypes": [] }, { "text": "'prompt-with-rationale'", "complexTypes": [] }, { "text": "'granted'", "complexTypes": [] }, { "text": "'denied'", "complexTypes": [] } ] }, { "name": "ButtonClickedEventListener", "slug": "buttonclickedeventlistener", "docs": "", "types": [ { "text": "(event: ButtonClickedEvent): void", "complexTypes": [ "ButtonClickedEvent" ] } ] }, { "name": "NotificationTappedEventListener", "slug": "notificationtappedeventlistener", "docs": "", "types": [ { "text": "(event: NotificationTappedEvent): void", "complexTypes": [ "NotificationTappedEvent" ] } ] } ], "pluginConfigs": [] }