# cordova-file-association

> 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

Latest version **1.0.0** (published 2016-03-16) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install cordova-file-association
pnpm add cordova-file-association
yarn add cordova-file-association
bun add cordova-file-association
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2016-03-16 |
| First published | 2016-03-16 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Marcin Faryna |
| Maintainers | farynam |
| Keywords | ecosystem:cordova, cordova-android |

## Links

- npm: https://www.npmjs.com/package/cordova-file-association
- Repository: https://github.com/farynam/cordova-fileAssociation
- Homepage: https://github.com/farynam/cordova-fileAssociation#readme
- Issues: https://github.com/farynam/cordova-fileAssociation/issues
- npm.io page: https://npm.io/package/cordova-file-association

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2016-03-16

## README

# 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:

....

<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTask" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
            ......
           <!--
                opening by file browser
            -->
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:host="*" android:pathPattern=".*\.json" android:scheme="file" />
            </intent-filter>

            <!--
                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>
        
  </activity>      
  
  3.Add plugin to project by:
  cordova plugin add <path to plugin location>/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 () {
                loadFromActivity();
            }, false);

            document.addEventListener("deviceready", function () {
                loadFromActivity();
            }, false);
  
  5.Use well

---
_Source: https://npm.io/package/cordova-file-association · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
