npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fsc-react-native-easy-downloader

v0.2.0

Published

Download files using system download manager and install apk files

Downloads

23

Readme

react-native-easy-downloader

A downloadManager for react-native to use system downloadManager(Show download progress in notifications) and install apk files on android.

Support multitasking and each task will have its own promise(callback).

Example code result

Example code result

Add it to your project

$ npm install react-native-easy-downloader --save

Then you can try linking the project automatically:

$ react-native link react-native-easy-downloader

or do it manually as described below:

Android

  1. in android/settings.gradle
...
include ':react-native-easy-downloader'
project(':react-native-easy-downloader').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-easy-downloader/android')
  1. in android/app/build.gradle add:
dependencies {
    ...
    compile project(':react-native-easy-downloader')
}
  1. and finally, in android/src/main/java/com/{YOUR_APP_NAME}/MainApplication.java add:
//...
import com.mayenjoy.RNDownloadManager.RNDownloadManager; // <--- This!
//...
@Override
protected List<ReactPackage> getPackages() {
  return Arrays.<ReactPackage>asList(
    new MainReactPackage(),
    new RNDownloadManager() // <---- and This!
  );
}

Permissions

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

API

Constants

The following constants are available on the RNFS export:

  • DirDownload (String) The absolute path to the system download directory
  • DirExternalStorage (String) The absolute path to the external storage, shared directory

download(options: object): Promise<path"">

options = {
  url: string;    // Reqired. URL to download file from
  title: string;     // Optional. The download title, will show in the notifications
  description: string;     // Optional. The download description
  savePath: string;     // Optional. Default the caches directory
  isAutoInstall: boolean;     // Optional. Default false. Whether install apk files after download finished (apk files only)
};

installApk(path: string): Promise

path: The path of apk file

Examples

Simple

import RNDM from 'react-native-easy-downloader';

const testUrl = 'http://img.rulili.com/xuanpin/software/1806/qhz_v2.0.5_20180606_update.apk';

// Within your render function
<View>
  <Button
    onPress={() => {
      RNDM.download({
        url: testUrl,
      }).then(
        ret => Alert.alert('Success', ret)
      ).catch (
        err => Alert.alert('Something wrong', err.message)
      )
    }}
    title="Download only"
    color="#841584"
  />

  <Button
    onPress={() => {
      RNDM.installApk('test').then(
        // success
      ).catch (
        err => Alert.alert('Something wrong', err.message)
      )
    }}
    title="Install only"
    color="#841584"
  />

  <Button
    onPress={() => {
      RNDM.download({
        url: testUrl,
        autoInstall: true,
        savePath: RNDM.DirDownload + '/test.apk',
        title: 'test',
        description: 'v2.0.5',
      }).then(
        ret => console.log('Success', ret)
      ).catch (
        err => Alert.alert('Something wrong', err.message)
      )
    }}
    title="Download and install"
    color="#841584"
  />

  <Text>Props:</Text>
  <Text>DirDownload: {RNDM.DirDownload}</Text>
  <Text>DirExternalStorage: {RNDM.DirExternalStorage}</Text>
</View>

License

License is MIT