GithubHelp home page GithubHelp logo

lucienbl / react-native-download-notification Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rodriguezmartin/react-native-download-notification

4.0 1.0 1.0 61 KB

Create, update and handle intents from Android notifications with progress bar in React Native. (With Oreo+ support) ๐Ÿ“ฉ

Java 85.74% JavaScript 14.26%

react-native-download-notification's Introduction

react-native-download-notification

Create, update and handle intents from Android notifications with progress bar in React Native.

Instalation

npm install rodriguezmartin/react-native-download-notification --save

Usage

// First import it
import  DownloadNotification  from  'react-native-download-notification';

// Create the function which will be called when the notification is tapped
intentHandler(intent){
  // intent is a String, depending on the notification state could be:
  //   'cancel' if download is on going
  //   'open' if it is set to completed
  //   'dismiss' if the user dismisses it
  if(intent === 'cancel'){
    // a reference of the notification tapped is binded
    this.setStateCancelled();
  }
}

// Create a notification
const notification = await DownloadNotification.create(
  'Document.pdf', // The notification title
  this.intentHandler // The intentHandler function created above
);

// Update the progress
notification.updateProgress(progress); // int from 0 to 100

// Set the finished state
notification.setStateCompleted();
notification.setStateCancelled();
notification.setStateFailed();

Customization

// You can globally customize the icon and labels of the notifications.
componentDidMount(){
  DownloadNotification.setup({
    icon: 'ic_launcher', // Default is the 'get_app' material icon.
    downloadingLabel: 'Downloading...', // Default is 'Downloading' 
    completedLabel: 'The download is complete', // Default is 'Download Completed'
    failedLabel: 'The download has failed', // Default is 'Download Failed'
    cancelledLabel: 'The download has been cancelled' // Default is 'Download Cancelled'
  });
}

react-native-download-notification's People

Contributors

lucienbl avatar rodriguezmartin avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

razorvlades

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.