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

react-native-notifier

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-notifier

Fast and simple in-app notifications for React Native

  • 0.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.1K
increased by29.51%
Maintainers
1
Weekly downloads
 
Created
Source

react-native-notifier

npm npm bundle size license MIT

Fast and simple in-app notifications for React Native

license MIT

Requirements

This library uses react-native-gesture-handler, perfect library for swipes and other gesture events.

If you are using react-navigation then you already have it. If you don't, check Getting Stated guide: https://software-mansion.github.io/react-native-gesture-handler/docs/getting-started.html

Installation

yarn add react-native-notifier

Or

npm install --save react-native-notifier

Usage

Wrap your app with NotifierWrapper

import { NotifierWrapper } from 'react-native-notifier';

const App = () => (
  <NotifierWrapper>
    <Navigation />
  </NotifierWrapper>
);

Or add NotifierRoot at end of your App.js component. Note that NotifierRoot should the last component to display notifications correctly

import { NotifierRoot } from 'react-native-notifier';

const App = () => (
  <>
    <Navigation />
    <NotifierRoot />
  </>
);

Then call Notifier.showNotification() anywhere in code

import { Notifier, Easing } from 'react-native-notifier';

Notifier.showNotification({
  title: 'John Doe',
  description: 'Hello! Can you help me with notifications?',
  duration: 0,
  showAnimationDuration: 800,
  showEasing: Easing.bounce,
  onHide: () => console.log('onHide'),
  onPress: () => console.log('Press'),
  hideOnPress: false,
});

API

showNotification

Notifier.showNotification(params: object);

Show notification with params.

params

NameTypeDefaultDescription
titleStringnullTitle of notification. Passed to Component.
descriptionStringnullDescription of notification. Passed to Component.
swipeEnabledBooleantrueCan notification be hidden by swiping it out
durationNumber3000Time after notification will disappear. Set to 0 to not hide notification automatically
ComponentComponentMainComponentYour custom component of notification body
componentPropsObject{}Additional props that will be passed to Component. Use it for customization or if using custom Component.
imageSourceObjectnullPassed to <Image /> as source param. Passed to Component.
animationDurationNumber300How fast notification will appear/disappear
showAnimationDurationNumberanimationDuration || 300How fast notification will appear.
hideAnimationDurationNumberanimationDuration || 300How fast notification will disappear.
easingEasingnullAnimation easing. Details: https://reactnative.dev/docs/easing
showEasingEasingeasing || nullShow Animation easing.
hideEasingEasingeasing || nullHide Animation easing.
onHideFunctionnullFunction called when notification started hiding
onPressFunctionnullFunction called when user press on notification
hideOnPressBooleantrueShould notification hide when user press on it
swipePixelsToCloseNumber20How many pixels user should swipe-up notification to dismiss it
swipeEasingEasingnullAnimation easing after user finished swiping
swipeAnimationDurationNumber200How fast should be animation after user finished swiping

hideNotification

Notifier.hideNotification(onHiddenCallback?: Function);

Hide notification and run callback function when notification completely hidden.

License

MIT

Keywords

FAQs

Package last updated on 24 Mar 2020

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc