JSPM

react-native-file-opener3

0.3.4
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q29116F
  • License MIT

A React Native module that allows you to open a file (mp3, mp4, pdf, word, excel, dwg etc.) on your device with its default application

Package Exports

  • react-native-file-opener3
  • react-native-file-opener3/react-native-file-opener.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-native-file-opener3) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

react-native-file-opener

A React Native module that allows you to open a file (mp3, mp4, pdf, word, excel, dwg etc.) on your device with its default application

New add podspec, pod manager. No need to react-native link this file.

iOS Android

Install

##iOS

  1. npm install react-native-file-opener3 --save

No link need! podspec added yet.

  1. Compile and have fun

##Android

  • npm install react-native-file-opener3 --save

##Usage

  1. In your React Native javascript code, bring in the native module
const FileOpener = require('react-native-file-opener3');
OR
import FileOpener from 'react-native-file-opener3';
  1. Basic usage
const FilePath = ...; // path of the file
const FileMimeType = ...; // mime type of the file
FileOpener.open(
    FilePath,
    FileMimeType
).then((msg) => {
    console.log('success!!')
},() => {
    console.log('error!!')
});

##Usage with react-native-fs

const RNFS = require('react-native-fs');
const FileOpener = require('react-native-file-opener3');

const SavePath = Platform.OS === 'ios' ? RNFS.DocumentDirectoryPath : RNFS.ExternalDirectoryPath;
const sampleDocFilePath = SavePath + '/sample.doc';

...

  function openSampleDoc() {
        FileOpener.open(
            sampleDocFilePath,
            'application/msword'
        ).then(() => {
            console.log('success!!');
        },(e) => {
            console.log('error!!');
        });

    }
    
...

##Demo project https://github.com/huangzuizui/react-native-file-opener-demo