# send-intent-listener

> This Capacitor plugin can be used in Ionic applications for receiving data from Intent.SEND_ACTION (works only for intent type "text/plain")

Latest version **0.0.2** (published 2020-05-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install send-intent-listener
pnpm add send-intent-listener
yarn add send-intent-listener
bun add send-intent-listener
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2020-05-20 |
| First published | 2020-05-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 362 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Dragos Atanasoae |
| Maintainers | dragos.atanasoae |
| Keywords | capacitor, plugin, native |

## Links

- npm: https://www.npmjs.com/package/send-intent-listener
- Repository: https://github.com/dragos-atanasoae/send-intent-listener
- Homepage: https://github.com/dragos-atanasoae/send-intent-listener#readme
- Issues: https://github.com/dragos-atanasoae/send-intent-listener.git/issues
- npm.io page: https://npm.io/package/send-intent-listener

## Dependencies (1)

- [@capacitor/core](https://npm.io/package/@capacitor/core.md) ^2.0.2

## Recent versions

- 0.0.2 (latest) — 2020-05-20
- 0.0.1 — 2020-05-19

## README

# send-intent-listener
### Capacitor plugin for receiving data(text/plain) in Ionic applications from Send Intent(Android)

```
npm i send-intent-listener
```

## Usage
```typescript
import { Plugins } from '@capacitor/core';
import { Platform } from '@ionic/angular';


const { SendIntentListener } = Plugins;

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
})
export class AppComponent {
  constructor(private platform: Platform) {
    this.initializeApp();
  }

  initializeApp() {
    this.platform.ready().then(() => {
      SendIntentListener.addListener('init', (event: any) => {
        // Retrieve text from Send Intent(share)
        console.log(event);
      });
      SendIntentListener.addListener('initError', (error: any) => {
        // Error
        console.error(error);
      });
    });
  }
}
```

# Android setup
## Step 1
Register the plugin in your Activity:
```diff
+ import android.content.Intent;
+ import com.adaslash.send_intent.SendIntentListener;

public class MainActivity extends BridgeActivity {
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Initializes the Bridge
    this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
      // Additional plugins you've installed go here
      // Ex: add(TotallyAwesomePlugin.class);
+     add(SendIntentListener.class);
    }});
  }

+ @Override
+ protected void onNewIntent(Intent intent) {
+   this.setIntent(intent);
+   super.onNewIntent(intent);
+ }
}
```

## Step 2
Add intent filter to AndroidManifest.xml
```xml
<intent-filter>
   <action android:name="android.intent.action.SEND" />
   <category android:name="android.intent.category.DEFAULT" />
   <data android:mimeType="text/plain" />
</intent-filter>
```

# iOS - comming soon

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