capacitor-timer-notification
A Capacitor plugin to create a timer notification that displays a countdown timer in the notification bar.
Stable Version is 0.24!!
Usage
Add the following to your android/app/src/main/AndroidManifest.xml
file to declare the necessary permissions and service:
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
<service
android:name=".TimerService"
android:enabled="true"
android:exported="false"
android:foregroundServiceType="mediaPlayback"/>
## Install
```bash
npm install capacitor-timer-notification
npx cap sync
API
startTimer(...)
startTimer(options: { duration: number; }) => Promise<void>
Starts the timer with a specified duration.
Param | Type | Description |
---|
options | { duration: number; } | Duration in seconds. |
stopTimer()
stopTimer() => Promise<void>
Stops the currently running timer.
getRemainingTime()
getRemainingTime() => Promise<{ remainingTime: number; }>
Gets the remaining time of the running timer.
Returns: Promise<{ remainingTime: number; }>
addListener('remainingTimeUpdate', ...)
addListener(eventName: "remainingTimeUpdate", listenerFn: (data: { remainingTime: number; }) => void) => Promise<PluginListenerHandle>
Listens for updates on the remaining time.
Param | Type | Description |
---|
eventName | 'remainingTimeUpdate' | Name of the event ('remainingTimeUpdate'). |
listenerFn | (data: { remainingTime: number; }) => void | Callback function with the remaining time. |
Returns: Promise<PluginListenerHandle>
Interfaces
PluginListenerHandle
Prop | Type |
---|
remove | () => Promise<void> |