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

react-native-push-notification-popup

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-push-notification-popup

React Native Push Notification Popup Component

  • 1.4.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5.8K
increased by151.92%
Maintainers
1
Weekly downloads
 
Created
Source

React Native Push Notification Popup

npm version GitHub license Maintenance Ask Me Anything !

iOS Preview Android Preview

Features

  • Support "pan" gesture
  • Support "onPress" gesture feedback
  • Written in pure-JS using official react-native Animation package
    • Which means it supports all Expo/CRNA apps
  • Support iPhone X, XS, Max (yeah that notch)
  • Support Android native "elevation"

Motivations

Blog post

  1. In some apps, you may just want to display reminders to user, without going through those troublesome push notification setups
  2. Expo/CNRA apps cannot display push notification while app is in foreground
  3. Even if you eject, you still need to configure iOS and Android separately with native codes

This package is here to help. Just show your own notification popup to your users!

Installation

# yarn, recommended
yarn add react-native-push-notification-popup

# or npm
npm install react-native-push-notification-popup --save

Usage

Declare Component

Put it in a wrapper component. (Maybe where you handle your incoming push notifications)

import NotificationPopup from 'react-native-push-notification-popup';

class MyComponent extends React.Component {
  render() {
    return (
      <View style={styles.container}>
        <MaybeYourNavigator />
        <NotificationPopup ref={ref => this.popup = ref} />
      </View>
    );
  }
// ...

IMPORTANT: Remember to put it on the bottom of other components, because React render from back to front in order of declaration. We do not use zIndex becuase it is problematic on Android.

Optional: Customize your popup
// Render function
const renderCustomPopup = ({ appIconSource, appTitle, timeText, title, body }) => (
  <View>
    <Text>{title}</Text>
    <Text>{body}</Text>
  </View>
);

class MyComponent extends React.Component {
  render() {
      return (
        <View style={styles.container}>
          <NotificationPopup
            ref={ref => this.popup = ref}
            renderPopupContent={renderCustomPopup} />
        </View>
      );
    }
// ...

Show it!

componentDidMount() {
  this.popup.show({
    onPress: function() {console.log('Pressed')},
    appIconSource: require('./assets/icon.jpg'),
    appTitle: 'Some App',
    timeText: 'Now',
    title: 'Hello World',
    body: 'This is a sample message.\nTesting emoji 😀',
    slideOutTime: 5000
  });
}

Props

ParamTypeDefaultDescription
renderPopupContentfunction
(options?: { appIconSource?: ImageSourcePropType; appTitle?: string; timeText?: string; title?: string;body?: string; }) => React.ReactElement<any>
nullRender your own custom popup body (Optional)

Methods

.show()
ParamTypeDefaultDescription
onPressFunctionnullCallback to be called when user press the popup
appIconSourceImage sourcenullIcon on the upper left
appTitleString''Usually your app name, but you can also customize it
timeTextString''Text on the upper right
titleString''Message title
bodyString''Message body (support multi-line)
slideOutTimeNumber4000Time until notification slides out

Roadmap

  • Add testing
  • Add example/ project
  • Support showing it globally
  • Customizing props: speed, duration, etc
  • Support image on the right-side
  • Android material design style
  • Other types of popup, e.g. without app icon
  • More usage examples
  • Identify peerDependencies on react-native

Contributing

Debugging

  1. Clone this repo
  2. Run yarn --production
    1. (Installing dependencies without --production will include devDependencies (e.g. react-native), which causes crashes)
  3. Create a react-native project next to it
  4. Add dependency to package.json
    1. "react-native-push-notification-popup": "file:../react-native-push-notification-popup"
  5. Try it
  6. Re-run yarn --production whenever there is any code change

Linting

  1. Run yarn (Install devDependencies)
  2. Run yarn run lint

License

MIT License. © Carson Wah 2018

Keywords

FAQs

Package last updated on 01 Sep 2019

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