You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

2.9 KiB

Daily Notification Plugin for Capacitor

A Capacitor plugin for scheduling and managing daily notifications with advanced features and robust error handling.

Features

  • Schedule daily notifications with custom time and content
  • Support for different priority levels
  • Timezone-aware scheduling
  • Offline support with caching
  • Comprehensive permission handling
  • Automatic retry logic
  • Detailed notification status tracking
  • Configurable settings management

Installation

npm install daily-notification-plugin
npx cap sync

iOS Setup

No additional setup required for iOS. The plugin automatically handles all necessary configurations.

Usage

Basic Usage

import { DailyNotification } from 'daily-notification-plugin';

// Schedule a daily notification
await DailyNotification.scheduleDailyNotification({
  url: 'https://api.example.com/updates',
  time: '09:00',
  title: 'Daily Update',
  body: 'Your daily update is ready'
});

Advanced Features

Custom Priority

await DailyNotification.scheduleDailyNotification({
  url: 'https://api.example.com/updates',
  time: '09:00',
  priority: 'high'
});

Timezone Support

await DailyNotification.scheduleDailyNotification({
  url: 'https://api.example.com/updates',
  time: '09:00',
  timezone: 'America/New_York'
});

Check Notification Status

const status = await DailyNotification.getNotificationStatus();
console.log('Notification status:', status);

Update Settings

await DailyNotification.updateSettings({
  sound: true,
  priority: 'high',
  timezone: 'America/Los_Angeles'
});

API Documentation

Methods

scheduleDailyNotification(options: ScheduleOptions)

Schedule a new daily notification.

getLastNotification()

Get information about the last delivered notification.

cancelAllNotifications()

Cancel all pending notifications.

getNotificationStatus()

Get current notification status and settings.

updateSettings(settings: NotificationSettings)

Update notification settings.

checkPermissions()

Check current notification permissions.

requestPermissions()

Request notification permissions.

Types

interface ScheduleOptions {
  url: string;
  time: string;
  title?: string;
  body?: string;
  sound?: boolean;
  priority?: 'high' | 'default' | 'low';
  timezone?: string;
}

interface NotificationSettings {
  sound?: boolean;
  priority?: string;
  timezone?: string;
}

Error Handling

The plugin provides detailed error messages for various scenarios:

  • Invalid parameters
  • Permission issues
  • Scheduling failures
  • Invalid time formats
  • Invalid timezone identifiers
  • Invalid priority values

Contributing

Contributions are welcome! Please read our contributing guidelines and submit pull requests to our GitHub repository.

License

MIT License - see LICENSE file for details