Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More

capacitor-timer-notification

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

capacitor-timer-notification

timer notifcation


Version published
Maintainers
0
Created

capacitor-timer-notification

A Capacitor plugin to create a timer notification that displays a countdown timer in the notification bar.

Usage

Please provide an audio file in the android/app/src/main/res/raw directory of your project. The plugin will use this audio file to play a sound when the timer is up.

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 the given duration in seconds.

ParamTypeDescription
options{ duration: number; }- Object containing the duration of the timer.

stopTimer()

stopTimer() => Promise<void>

Stops the currently running timer.


pauseTimer()

pauseTimer() => Promise<void>

Pauses the currently running timer.


resumeTimer()

resumeTimer() => Promise<void>

Resumes the paused timer.


addListener('remainingTimeUpdate', ...)

addListener(eventName: 'remainingTimeUpdate', listenerFunc: (data: { remainingTime: number; }) => void) => Promise<PluginListenerHandle>

Listens for updates on the remaining time of the timer.

ParamTypeDescription
eventName'remainingTimeUpdate'- The name of the event, e.g., "remainingTimeUpdate".
listenerFunc(data: { remainingTime: number; }) => void- Callback function that receives the remaining time.

Returns: Promise<PluginListenerHandle>


removeAllListeners(...)

removeAllListeners(eventName: string) => Promise<void>

Removes all listeners for a given event.

ParamTypeDescription
eventNamestring- The name of the event to remove listeners for.

Interfaces

PluginListenerHandle
PropType
remove() => Promise<void>

FAQs

Package last updated on 21 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts