npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

capacitor-open-in-app

v0.2.0

Published

Capacitor plugin for receiving shared files from other apps

Readme

capacitor-open-in-app

A Capacitor plugin for receiving shared files (PDFs, images, text, URLs) from other apps on iOS and Android.

Installation

npm install capacitor-open-in-app
npx cap sync

Configuration

import type { OpenInAppConfig } from 'capacitor-open-in-app';
import { configure } from 'capacitor-open-in-app';

const config: OpenInAppConfig = {
  allowedTypes: ['pdf', 'image'],
};

configure(config);

Configuration is applied in JavaScript helper functions (getItemsByType, getPdfs, getImages) and does not change the low-level OpenInApp.getItems() result.

API

getItems()

Returns all pending shared items and clears the internal queue on the native side (one-shot call).

import { OpenInApp } from 'capacitor-open-in-app';

const { items } = await OpenInApp.getItems();
items.forEach(item => {
  console.log(item.type, item.path, item.fileName);
});

Helper Functions

import { configure, getItemsByType, getPdfs, getImages } from 'capacitor-open-in-app';

configure({ allowedTypes: ['pdf', 'image'] });

// Get all PDFs
const pdfs = await getPdfs();

// Get all images
const images = await getImages();

// Get items by type
const textItems = await getItemsByType('text');

Types

type SharedItemType = 'file' | 'image' | 'pdf' | 'text' | 'url' | 'unknown';

interface SharedItem {
  id: string;
  type: SharedItemType;
  mimeType?: string;
  fileName?: string;
  fileExtension?: string;
  path?: string;
  url?: string;
  size?: number;
  createdAt?: string;
}

interface OpenInAppConfig {
  allowedTypes?: SharedItemType[];
}

Shared item type matrix

| type | When it appears | Guaranteed fields | |---------|---------------------------------------------------------|----------------------------| | pdf | PDF files detected by extension or application/pdf | id, type, path | | image | Image files where MIME starts with image/ | id, type, path | | text | Text-based content (MIME starts with text/ or .txt) | id, type | | url | Reserved for URL-only shares | id, type, url | | file | Other files that are not mapped to a more specific type | id, type, path | | unknown | No reliable MIME or extension information | id, type |

iOS Setup

1. Add Document Types to Info.plist

Register the file types that your app should be able to open from other apps. Example below shows a PDF configuration:

<key>CFBundleDocumentTypes</key>
<array>
  <dict>
    <key>CFBundleTypeName</key>
    <string>PDF Document</string>
    <key>LSHandlerRank</key>
    <string>Default</string>
    <key>LSItemContentTypes</key>
    <array>
      <string>com.adobe.pdf</string>
    </array>
  </dict>
</array>

You can add more <dict> entries or additional UTIs inside LSItemContentTypes for any other file types your app supports.

2. Forward URLs in AppDelegate.swift

In your existing AppDelegate, forward incoming file URLs to the plugin and then let Capacitor handle the rest:

import UIKit
import Capacitor
import OpenInAppPlugin

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
    var window: UIWindow?

    func application(
        _ app: UIApplication,
        open url: URL,
        options: [UIApplication.OpenURLOptionsKey: Any] = [:]
    ) -> Bool {
        OpenInAppPlugin.handleIncomingURLs([url])
        return ApplicationDelegateProxy.shared.application(app, open: url, options: options)
    }
}

If you use CAPAppDelegate as a base class, call super.application instead of ApplicationDelegateProxy.shared.application.

Android Setup

1. Register the Plugin

In your MainActivity.java or MainActivity.kt:

import com.openinapp.plugin.OpenInAppPlugin

class MainActivity : BridgeActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        registerPlugin(OpenInAppPlugin::class.java)
        super.onCreate(savedInstanceState)
    }
}

2. Add Intent Filters (optional customization)

The plugin includes default intent filters for receiving shared files. To customize, modify your app's AndroidManifest.xml:

<activity
    android:name=".MainActivity"
    android:exported="true">
    
    <intent-filter>
        <action android:name="android.intent.action.SEND" />
        <category android:name="android.intent.category.DEFAULT" />
        <data android:mimeType="application/pdf" />
    </intent-filter>
    
</activity>

Usage Example

import { App } from '@capacitor/app';
import { getPdfs } from 'capacitor-open-in-app';

const checkSharedItems = async () => {
  const pdfs = await getPdfs();
  const pdf = pdfs[0];
  if (pdf?.path) {
    await handlePdfUpload(pdf.path);
  }
};

App.addListener('appUrlOpen', async () => {
  await checkSharedItems();
});

onMounted(() => {
  checkSharedItems();
});

Troubleshooting iOS

  • Make sure CFBundleDocumentTypes is set correctly in Info.plist for the file types you expect.
  • Verify that application(_:open:options:) in AppDelegate forwards URLs to OpenInAppPlugin.handleIncomingURLs.
  • If you change Info.plist, clean the build and reinstall the app on the device or simulator.

Local development and testing

npm install
npm run lint
npm test
npm run build

To try the plugin in a Capacitor app locally:

cd capacitor-open-in-app
npm link

cd ../your-capacitor-app
npm link capacitor-open-in-app
npx cap sync

Releasing

  • Bump the version in package.json.
  • Build the package:
npm run build
  • Publish to npm (requires correct auth):
npm publish

License

MIT