Skip to content

File association plugin for cordova. Main purpose is to make possible to assciate cordova app with file types well known or custom made.

License

Notifications You must be signed in to change notification settings

farynam/cordova-fileAssociation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cordova-fileAssociation

File association plugin for cordova. Main purpose is to make possible to associate cordova app with file types well known or custom made. Currently it is for Android only.

How to use it 1.Clone from git git clone 2.Configure your AndroidManifest.xml activity for example for json file:

....

......
        <!--
            opening by email application
        -->
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="application/json" />
        </intent-filter>

        <!--
            opening from remote ex. with http (ex. browser)
        -->
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.BROWSABLE" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:scheme="http" />
            <data android:host="*" />
            <data android:pathPattern=".*\\.json" />
        </intent-filter>
        .....
    </activity>

3.Add plugin to project by: cordova plugin add /FileAssociation

4.Register listeners in your cordova app to be sure that plugin is available to use:

var fileAssociation = function () { if (!window.plugins) { console.log("plugins not defined"); return; }

            window.plugins.fileAssociation.getAssociatedData(null,
                function (success) {
                    try {
                        if (success != null) {
                            //handle your data here maybe ex. by promise 
                            activityPromise.resolve(decoded);
                        }
                    } catch (e) {
                        activityPromise.reject(e);
                    }
                }, function (error) {
                    activityPromise.reject(error);
                });
        };

//added to be sure that plgin is available
document.addEventListener("resume", function () { fileAssociation(); }, false);

        document.addEventListener("deviceready", function () {
            fileAssociation();
        }, false);

5.Use well

About

File association plugin for cordova. Main purpose is to make possible to assciate cordova app with file types well known or custom made.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published