Coder Social home page Coder Social logo

siegfriedbolz / cordova-plugin-file-opener2 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pwlin/cordova-plugin-file-opener2

1.0 2.0 0.0 105 KB

A File Opener Plugin for Cordova

License: MIT License

Java 49.55% Objective-C 43.98% JavaScript 6.46%

cordova-plugin-file-opener2's Introduction

A File Opener Plugin for Cordova

This plugin will open a file on your device file system with its default application.

Changed iOS-part:

NSURL *fileURL  = [NSURL URLWithString:path]; 

to

NSURL *fileURL  = [NSURL fileURLWithPath:path]; 

In Cordova 3.4.0 (and above) use entry.toNativeURL() for first parameter. Hint: http://stackoverflow.com/questions/21756274/phonegap-ios-why-when-i-get-the-full-path-of-the-filesystem-in-a-device-or-s

Requirements

  • Android 4+ / iOS 6, 7 and 8 (new!)
  • Cordova 3.0 or higher (tested with 3.5)

Installation

cordova plugin add https://github.com/siegfriedbolz/cordova-plugin-file-opener2.git

PhoneGap Build

This Plugin is available at the PhoneGap Build Repository:

Usage

Open an APK install dialog:

<script>
    cordova.plugins.fileOpener2.open(
        '/sdcard/Download/gmail.apk', 
        'application/vnd.android.package-archive'
    );
</script>

Open a PDF document with the default PDF reader and optional callback object:

<script>
    cordova.plugins.fileOpener2.open(
	    '/sdcard/Download/starwars.pdf', 
	    'application/pdf', 
	    { 
		    error : function(errorObj) { 
			    alert('Error status: ' + errorObj.status + ' - Error message: ' + errorObj.message); 
		    },
		    success : function () {
			    alert('file opened successfully'); 				
		    }
	    }
    );
</script>

Please Note that for properly opening a PDF file, you must already have a PDF reader (Acrobat Reader, Foxit Mobile PDF, etc. ) installed on your mobile device. Otherwise this will not work.

cordova-plugin-file-opener2's People

Contributors

pwlin avatar cqfsbolz avatar break24 avatar

Stargazers

Gaurav Sukhatme avatar

Watchers

James Cloos avatar Siegfried-Thor Bolz avatar

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.