@umituz/react-native-notifications
v1.1.1
Published
Offline-first local notifications system for React Native apps using expo-notifications
Maintainers
Readme
@umituz/react-native-notifications
Offline-first local notifications system for React Native apps using expo-notifications.
Installation
npm install @umituz/react-native-notificationsPeer Dependencies
react>= 18.2.0react-native>= 0.74.0expo-notifications~0.28.0expo-device~6.0.2@react-native-async-storage/async-storage>= 1.21.0zustand>= 5.0.2
Features
- ✅ Offline-first local notifications
- ✅ Schedule notifications for specific dates/times
- ✅ Repeating notifications (daily, weekly, monthly)
- ✅ Android notification channels
- ✅ Permission handling
- ✅ Cancel individual or all notifications
- ✅ Works completely offline (no backend required)
- ✅ Zustand state management
Usage
Basic Usage
import { NotificationService, useNotificationSettings } from '@umituz/react-native-notifications';
// Request permissions
const hasPermissions = await NotificationService.getInstance().requestPermissions();
// Schedule a notification
const notificationId = await notificationService.notifications.scheduleNotification({
title: 'Reminder',
body: 'Don\'t forget to check your tasks!',
trigger: { type: 'date', date: new Date('2025-01-15T09:00:00') }
});
// Daily reminder
const dailyId = await notificationService.notifications.scheduleNotification({
title: 'Daily Workout',
body: 'Time for your morning workout!',
trigger: { type: 'daily', hour: 7, minute: 0 }
});Using Hooks
import { useNotificationSettings, useNotificationsStore } from '@umituz/react-native-notifications';
const MyComponent = () => {
const { notificationsEnabled, setNotificationsEnabled } = useNotificationSettings();
const { hasPermissions } = useNotificationsStore();
return (
<Switch
value={notificationsEnabled}
onValueChange={setNotificationsEnabled}
/>
);
};API
NotificationService
requestPermissions(): Request notification permissionshasPermissions(): Check if permissions are grantednotifications.scheduleNotification(options): Schedule a notificationnotifications.cancelNotification(id): Cancel a notificationnotifications.cancelAllNotifications(): Cancel all notificationsnotifications.getScheduledNotifications(): Get all scheduled notifications
Hooks
useNotificationSettings(): Manage notification settingsuseNotificationsStore(): Access notification state
License
MIT
