0.4.0 • Published 1 year ago

@guulabs/react-native-local-notifications v0.4.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Schedule local notifications from React Native on iOS and Android.

Installation

yarn add @guulabs/react-native-local-notifications

Usage

import {
  scheduleNotification,
  cancelScheduledNotifications,
  cancelAllScheduledNotifications,
} from '@guulabs/react-native-local-notifications';

// ...

const id = await scheduleNotification(
  {
    title: 'Title',
    body: 'This is the body of the local notification.',
  },
  {
    timestamp: Date.now() + 5000,
  }
);

// Cancel a list of notification ids
await cancelScheduledNotifications([id, "another_id1", "another_id2"]);

// Cancel all
await cancelAllScheduledNotifications();

Android

Set a custom icon and set an accent color.

const id = await scheduleNotification(
  {
    title: 'Title',
    body: 'This is the body of the local notification.',
    android: {
      smallIcon: 'ic_launcher',
      color: '#0000ff',
    }
  },
  {
    timestamp: Date.now() + 5000,
  }
);

API

Param nameTypeDefaultDescription
titlestring-Title of the local notification.
bodystring-The body for the local notification.
android{ smallIcon: string, color: string }{ smallIcon: 'ic_launcher' }Use smallIcon to set a custom resource name (drawable or mipmap) for the notification icon on Android. Use color to set a hex accent color for the notification on Android.
timestampnumber-The date in milliseconds when the local notfication should be dispatched.

Should I use it?

This library was desinged to minimize the JS footprint, it contains only a few fuctions defined on the JS side. If your use case requires more than sending some simple local notifications, I strongly advive to use Notifee.

Show your support

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library

0.4.0

1 year ago

0.3.0

1 year ago

0.2.0

1 year ago