{"id":42113618,"url":"https://github.com/cap-go/capacitor-share-target","last_synced_at":"2026-02-16T09:38:35.426Z","repository":{"id":321004771,"uuid":"1084037950","full_name":"Cap-go/capacitor-share-target","owner":"Cap-go","description":"Capacitor plugin to receive share target intent in app","archived":false,"fork":false,"pushed_at":"2026-01-12T14:08:46.000Z","size":264,"stargazers_count":4,"open_issues_count":4,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-12T16:27:33.767Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Cap-go.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"Cap-go","patreon":null,"open_collective":"capgo","ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2025-10-27T06:07:06.000Z","updated_at":"2026-01-12T14:07:37.000Z","dependencies_parsed_at":"2025-10-27T09:17:56.797Z","dependency_job_id":"7c0871e4-d5c4-4ccc-90bc-2b405bf18c77","html_url":"https://github.com/Cap-go/capacitor-share-target","commit_stats":null,"previous_names":["cap-go/capacitor-share-target"],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/Cap-go/capacitor-share-target","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cap-go%2Fcapacitor-share-target","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cap-go%2Fcapacitor-share-target/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cap-go%2Fcapacitor-share-target/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cap-go%2Fcapacitor-share-target/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cap-go","download_url":"https://codeload.github.com/Cap-go/capacitor-share-target/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cap-go%2Fcapacitor-share-target/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28780002,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-26T13:55:28.044Z","status":"ssl_error","status_checked_at":"2026-01-26T13:55:26.068Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-26T14:00:53.710Z","updated_at":"2026-02-02T09:22:56.378Z","avatar_url":"https://github.com/Cap-go.png","language":"Java","funding_links":["https://github.com/sponsors/Cap-go","https://opencollective.com/capgo"],"categories":[],"sub_categories":[],"readme":"# @capgo/capacitor-share-target\n\nCapacitor plugin to receive shared content from other apps.\n\n## Compatibility\n\n| Plugin version | Capacitor compatibility | Maintained |\n| -------------- | ----------------------- | ---------- |\n| v8.\\*.\\*       | v8.\\*.\\*                | ✅          |\n| v7.\\*.\\*       | v7.\\*.\\*                | On demand   |\n| v6.\\*.\\*       | v6.\\*.\\*                | ❌          |\n| v5.\\*.\\*       | v5.\\*.\\*                | ❌          |\n\n\u003e **Note:** The major version of this plugin follows the major version of Capacitor. Use the version that matches your Capacitor installation (e.g., plugin v8 for Capacitor 8). Only the latest major version is actively maintained.\n\n## Install\n\n```bash\nnpm install @capgo/capacitor-share-target\nnpx cap sync\n```\n\n## Configuration\n\n### Android\n\nAdd the following to your `AndroidManifest.xml` inside the `\u003cactivity\u003e` tag to allow your app to receive shared content:\n\n```xml\n\u003cintent-filter\u003e\n    \u003caction android:name=\"android.intent.action.SEND\" /\u003e\n    \u003ccategory android:name=\"android.intent.category.DEFAULT\" /\u003e\n    \u003cdata android:mimeType=\"text/*\" /\u003e\n\u003c/intent-filter\u003e\n\u003cintent-filter\u003e\n    \u003caction android:name=\"android.intent.action.SEND\" /\u003e\n    \u003ccategory android:name=\"android.intent.category.DEFAULT\" /\u003e\n    \u003cdata android:mimeType=\"image/*\" /\u003e\n\u003c/intent-filter\u003e\n\u003cintent-filter\u003e\n    \u003caction android:name=\"android.intent.action.SEND_MULTIPLE\" /\u003e\n    \u003ccategory android:name=\"android.intent.category.DEFAULT\" /\u003e\n    \u003cdata android:mimeType=\"image/*\" /\u003e\n\u003c/intent-filter\u003e\n```\n\nYou can customize the `mimeType` to match the types of content you want to receive (e.g., `text/*`, `image/*`, `video/*`, `*/*`).\n\n### iOS\n\nFor iOS, you need to create a Share Extension to receive shared content. This requires additional setup:\n\n1. In Xcode, go to File \u003e New \u003e Target\n2. Select \"Share Extension\" and click Next\n3. Name it (e.g., \"ShareExtension\") and click Finish\n4. Configure the Share Extension to save data to a shared App Group (e.g., `group.com.yourcompany.app`)\n5. Configure the plugin in your `capacitor.config.ts` or `capacitor.config.json`:\n\n```typescript\n{\n  plugins: {\n    CapacitorShareTarget: {\n      appGroupId: \"group.com.yourcompany.app\"\n    }\n  }\n}\n```\n\n6. In your ShareViewController.swift, save the shared data using the key `\"share-target-data\"` or `\"SharedData\"` to UserDefaults with your app group ID\n\nExample ShareViewController.swift:\n\n```swift\nimport UIKit\nimport UniformTypeIdentifiers\n\nclass ShareViewController: UIViewController {\n    let APP_GROUP_ID = \"group.com.yourcompany.app\"  // Same as in capacitor.config\n    let APP_URL_SCHEME = \"yourapp\"  // Your app's URL scheme\n    \n    private var texts: [[String: Any]] = []\n    private var files: [[String: Any]] = []\n\n    override public func viewDidLoad() {\n        super.viewDidLoad()\n        \n        guard let extensionItem = extensionContext?.inputItems.first as? NSExtensionItem,\n              let attachments = extensionItem.attachments else {\n            self.exit()\n            return\n        }\n\n        Task {\n            // Process attachments...\n            // (See full implementation in issue examples)\n            \n            // Save to UserDefaults\n            let shareData: [String: Any] = [\n                \"title\": extensionItem.attributedTitle?.string ?? \"\",\n                \"texts\": texts,\n                \"files\": files\n            ]\n            \n            let userDefaults = UserDefaults(suiteName: APP_GROUP_ID)\n            userDefaults?.set(shareData, forKey: \"share-target-data\")\n            userDefaults?.synchronize()\n            \n            // Open main app with your URL scheme\n            let url = URL(string: \"\\(APP_URL_SCHEME)://share\")!\n            self.openURL(url)\n        }\n    }\n    \n    // ... rest of implementation\n}\n```\n\nFor detailed instructions, see the [iOS Share Extension documentation](https://developer.apple.com/documentation/uikit/uiactivityviewcontroller).\n\n## Usage\n\n```typescript\nimport { CapacitorShareTarget } from '@capgo/capacitor-share-target';\n\n// Listen for shared content\nCapacitorShareTarget.addListener('shareReceived', (event) =\u003e {\n  console.log('Title:', event.title);\n  console.log('Texts:', event.texts);\n\n  event.files?.forEach(file =\u003e {\n    console.log(`File: ${file.name}`);\n    console.log(`Type: ${file.mimeType}`);\n    console.log(`URI: ${file.uri}`);\n  });\n});\n```\n\n## API\n\n\u003cdocgen-index\u003e\n\n* [`addListener('shareReceived', ...)`](#addlistenersharereceived-)\n* [`removeAllListeners()`](#removealllisteners)\n* [`getPluginVersion()`](#getpluginversion)\n* [Interfaces](#interfaces)\n\n\u003c/docgen-index\u003e\n\n\u003cdocgen-api\u003e\n\u003c!--Update the source file JSDoc comments and rerun docgen to update the docs below--\u003e\n\nCapacitor Share Target Plugin interface.\n\nThis plugin allows your application to receive content shared from other apps.\nUsers can share text, URLs, and files to your app from other applications.\n\n### addListener('shareReceived', ...)\n\n```typescript\naddListener(eventName: 'shareReceived', listenerFunc: (event: ShareReceivedEvent) =\u003e void) =\u003e Promise\u003cPluginListenerHandle\u003e\n```\n\nListen for shareReceived event.\n\nRegisters a listener that will be called when content is shared to the application\nfrom another app. The callback receives event data containing title, texts, and files.\n\n| Param              | Type                                                                                  | Description                                                  |\n| ------------------ | ------------------------------------------------------------------------------------- | ------------------------------------------------------------ |\n| **`eventName`**    | \u003ccode\u003e'shareReceived'\u003c/code\u003e                                                          | The event name. Must be 'shareReceived'.                     |\n| **`listenerFunc`** | \u003ccode\u003e(event: \u003ca href=\"#sharereceivedevent\"\u003eShareReceivedEvent\u003c/a\u003e) =\u0026gt; void\u003c/code\u003e | Callback function invoked when content is shared to the app. |\n\n**Returns:** \u003ccode\u003ePromise\u0026lt;\u003ca href=\"#pluginlistenerhandle\"\u003ePluginListenerHandle\u003c/a\u003e\u0026gt;\u003c/code\u003e\n\n**Since:** 0.1.0\n\n--------------------\n\n\n### removeAllListeners()\n\n```typescript\nremoveAllListeners() =\u003e Promise\u003cvoid\u003e\n```\n\nRemove all listeners for this plugin.\n\n**Since:** 0.1.0\n\n--------------------\n\n\n### getPluginVersion()\n\n```typescript\ngetPluginVersion() =\u003e Promise\u003c{ version: string; }\u003e\n```\n\nGet the native Capacitor plugin version.\n\nReturns the current version of the native plugin implementation.\n\n**Returns:** \u003ccode\u003ePromise\u0026lt;{ version: string; }\u0026gt;\u003c/code\u003e\n\n**Since:** 0.1.0\n\n--------------------\n\n\n### Interfaces\n\n\n#### PluginListenerHandle\n\n| Prop         | Type                                      |\n| ------------ | ----------------------------------------- |\n| **`remove`** | \u003ccode\u003e() =\u0026gt; Promise\u0026lt;void\u0026gt;\u003c/code\u003e |\n\n\n#### ShareReceivedEvent\n\nEvent data received when content is shared to the application.\n\n| Prop        | Type                      | Description                                      | Since |\n| ----------- | ------------------------- | ------------------------------------------------ | ----- |\n| **`title`** | \u003ccode\u003estring\u003c/code\u003e       | The title of the shared content.                 | 0.1.0 |\n| **`texts`** | \u003ccode\u003estring[]\u003c/code\u003e     | Array of text content shared to the application. | 0.1.0 |\n| **`files`** | \u003ccode\u003eSharedFile[]\u003c/code\u003e | Array of files shared to the application.        | 0.2.0 |\n\n\n#### SharedFile\n\nRepresents a file shared to the application.\n\n| Prop           | Type                | Description                                                                                                                             | Since |\n| -------------- | ------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | ----- |\n| **`uri`**      | \u003ccode\u003estring\u003c/code\u003e | The URI of the shared file. On Android/iOS this will be a file path or data URL. On web this will be a cached URL accessible via fetch. | 0.1.0 |\n| **`name`**     | \u003ccode\u003estring\u003c/code\u003e | The name of the shared file, with or without extension.                                                                                 | 0.1.0 |\n| **`mimeType`** | \u003ccode\u003estring\u003c/code\u003e | The MIME type of the shared file.                                                                                                       | 0.1.0 |\n\n\u003c/docgen-api\u003e\n\n## Example\n\nHere's a complete example of handling shared content in your app:\n\n```typescript\nimport { CapacitorShareTarget } from '@capgo/capacitor-share-target';\nimport { Capacitor } from '@capacitor/core';\n\nexport class ShareService {\n  async initialize() {\n    // Only add listener on native platforms\n    if (Capacitor.isNativePlatform()) {\n      await CapacitorShareTarget.addListener('shareReceived', this.handleSharedContent);\n    }\n  }\n\n  private handleSharedContent(event: ShareReceivedEvent) {\n    console.log('Received shared content!');\n\n    // Handle shared text\n    if (event.texts.length \u003e 0) {\n      console.log('Shared text:', event.texts[0]);\n      // Process the shared text (e.g., URL, note, etc.)\n    }\n\n    // Handle shared files\n    if (event.files.length \u003e 0) {\n      event.files.forEach(async (file) =\u003e {\n        console.log(`Processing file: ${file.name}`);\n\n        if (file.mimeType.startsWith('image/')) {\n          // Handle image files\n          await this.processImage(file.uri);\n        } else if (file.mimeType.startsWith('video/')) {\n          // Handle video files\n          await this.processVideo(file.uri);\n        }\n      });\n    }\n  }\n\n  private async processImage(uri: string) {\n    // Your image processing logic here\n  }\n\n  private async processVideo(uri: string) {\n    // Your video processing logic here\n  }\n\n  async cleanup() {\n    await CapacitorShareTarget.removeAllListeners();\n  }\n}\n```\n\n## Contributing\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md).\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcap-go%2Fcapacitor-share-target","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcap-go%2Fcapacitor-share-target","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcap-go%2Fcapacitor-share-target/lists"}