{"id":13554668,"url":"https://github.com/KasemJaffer/receive_sharing_intent","last_synced_at":"2025-04-03T07:32:12.461Z","repository":{"id":34912647,"uuid":"189476052","full_name":"KasemJaffer/receive_sharing_intent","owner":"KasemJaffer","description":"A Flutter plugin that enables flutter apps to receive sharing photos, text and url from other apps.","archived":false,"fork":false,"pushed_at":"2024-12-03T16:55:47.000Z","size":8729,"stargazers_count":336,"open_issues_count":211,"forks_count":403,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-12-03T17:51:51.983Z","etag":null,"topics":["image","intent","media","share","video"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KasemJaffer.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"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}},"created_at":"2019-05-30T20:12:27.000Z","updated_at":"2024-12-03T16:57:34.000Z","dependencies_parsed_at":"2024-04-29T17:57:16.709Z","dependency_job_id":"734b908c-cf80-4a03-95c6-262970c0be2e","html_url":"https://github.com/KasemJaffer/receive_sharing_intent","commit_stats":{"total_commits":120,"total_committers":15,"mean_commits":8.0,"dds":0.4833333333333333,"last_synced_commit":"c1403bb2d718866f83a3b5a47c6a119bc8401ed5"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KasemJaffer%2Freceive_sharing_intent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KasemJaffer%2Freceive_sharing_intent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KasemJaffer%2Freceive_sharing_intent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KasemJaffer%2Freceive_sharing_intent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KasemJaffer","download_url":"https://codeload.github.com/KasemJaffer/receive_sharing_intent/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246956621,"owners_count":20860470,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["image","intent","media","share","video"],"created_at":"2024-08-01T12:02:52.616Z","updated_at":"2025-04-03T07:32:12.454Z","avatar_url":"https://github.com/KasemJaffer.png","language":"Swift","funding_links":[],"categories":["Swift"],"sub_categories":[],"readme":"# receive_sharing_intent\n[![pub package](https://img.shields.io/pub/v/receive_sharing_intent.svg)](https://pub.dev/packages/receive_sharing_intent)\n\nA Flutter plugin that enables flutter apps to receive sharing photos, videos, text, urls or any other file types from another app.\n\nAlso, supports iOS Share extension and launching the host app automatically.\nCheck the provided [example](./example/lib/main.dart) for more info.\n\n\n\n|             | Android                 | iOS               |\n|-------------|-------------------------|-------------------|\n| **Support** | SDK 19+ (Kotlin 1.9.22) | 12.0+ (Swift 5.0) |\n\n\n\n![Alt Text](./example/demo.gif)\n\n\n# Usage\n\nTo use this plugin, add `receive_sharing_intent` as a [dependency in your pubspec.yaml file](https://flutter.io/platform-plugins/). For example:\n\n```yaml\ndependencies:\n  receive_sharing_intent: ^latest\n```\n\n## Android\n\nAdd the following filters to your [android/app/src/main/AndroidManifest.xml](./example/android/app/src/main/AndroidManifest.xml):\n\n```xml\n\u003cmanifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n.....\n \u003cuses-permission android:name=\"android.permission.READ_EXTERNAL_STORAGE\"/\u003e\n\n  \u003capplication\n        android:name=\"io.flutter.app.FlutterApplication\"\n        ...\n        \u003e\n\u003c!--Set activity launchMode to singleTask, if you want to prevent creating new activity instance everytime there is a new intent.--\u003e\n    \u003cactivity\n            android:name=\".MainActivity\"\n            android:launchMode=\"singleTask\"\n            android:theme=\"@style/LaunchTheme\"\n            android:configChanges=\"orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode\"\n            android:hardwareAccelerated=\"true\"\n            android:windowSoftInputMode=\"adjustResize\"\u003e\n\n            \u003c!--TODO:  Add this filter, if you want support opening urls into your app--\u003e\n            \u003cintent-filter\u003e\n               \u003caction android:name=\"android.intent.action.VIEW\" /\u003e\n               \u003ccategory android:name=\"android.intent.category.DEFAULT\" /\u003e\n               \u003ccategory android:name=\"android.intent.category.BROWSABLE\" /\u003e\n               \u003cdata\n                   android:scheme=\"https\"\n                   android:host=\"example.com\"\n                   android:pathPrefix=\"/invite\"/\u003e\n            \u003c/intent-filter\u003e\n\n            \u003c!--TODO:  Add this filter, if you want support opening files into your app--\u003e\n            \u003cintent-filter\u003e\n              \u003caction android:name=\"android.intent.action.VIEW\" /\u003e\n              \u003ccategory android:name=\"android.intent.category.DEFAULT\" /\u003e\n              \u003cdata\n                   android:mimeType=\"*/*\"\n                   android:scheme=\"content\" /\u003e\n            \u003c/intent-filter\u003e\n\n             \u003c!--TODO: Add this filter, if you want to support sharing text into your app--\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=\"text/*\" /\u003e\n            \u003c/intent-filter\u003e\n\n            \u003c!--TODO: Add this filter, if you want to support sharing images into your app--\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\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             \u003c!--TODO: Add this filter, if you want to support sharing videos into your app--\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=\"video/*\" /\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=\"video/*\" /\u003e\n            \u003c/intent-filter\u003e\n\n            \u003c!--TODO: Add this filter, if you want to support sharing any type of files--\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=\"*/*\" /\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=\"*/*\" /\u003e\n            \u003c/intent-filter\u003e\n      \u003c/activity\u003e\n\n  \u003c/application\u003e\n\u003c/manifest\u003e\n....\n```\n\n## iOS\n\n#### 1. Create Share Extension\n\n- Using Xcode, go to File/New/Target and Choose \"Share Extension\".\n- Give it a name, i.e., \"Share Extension\".\n\nMake sure the deployment target for Runner.app and the share extension is the same.\n\n#### 2. Replace your [ios/Share Extension/Info.plist](./example/ios/Share%20Extension/Info.plist) with the following:\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003c!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\"\u003e\n\u003cplist version=\"1.0\"\u003e\n  \u003cdict\u003e\n    \u003ckey\u003eAppGroupId\u003c/key\u003e\n    \u003cstring\u003e$(CUSTOM_GROUP_ID)\u003c/string\u003e\n\t\u003ckey\u003eCFBundleVersion\u003c/key\u003e\n\t\u003cstring\u003e$(FLUTTER_BUILD_NUMBER)\u003c/string\u003e\n\t\u003ckey\u003eNSExtension\u003c/key\u003e\n\t\u003cdict\u003e\n\t\t\u003ckey\u003eNSExtensionAttributes\u003c/key\u003e\n        \u003cdict\u003e\n            \u003ckey\u003ePHSupportedMediaTypes\u003c/key\u003e\n               \u003carray\u003e\n                    \u003c!--TODO: Add this flag, if you want to support sharing video into your app--\u003e\n                   \u003cstring\u003eVideo\u003c/string\u003e\n                   \u003c!--TODO: Add this flag, if you want to support sharing images into your app--\u003e\n                   \u003cstring\u003eImage\u003c/string\u003e\n               \u003c/array\u003e\n            \u003ckey\u003eNSExtensionActivationRule\u003c/key\u003e\n            \u003cdict\u003e\n                \u003c!--TODO: Add this flag, if you want to support sharing text into your app--\u003e\n                \u003ckey\u003eNSExtensionActivationSupportsText\u003c/key\u003e\n                \u003ctrue/\u003e\n                \u003c!--TODO: Add this tag, if you want to support sharing urls into your app--\u003e\n            \t\u003ckey\u003eNSExtensionActivationSupportsWebURLWithMaxCount\u003c/key\u003e\n            \t\u003cinteger\u003e1\u003c/integer\u003e\n            \t\u003c!--TODO: Add this flag, if you want to support sharing images into your app--\u003e\n                \u003ckey\u003eNSExtensionActivationSupportsImageWithMaxCount\u003c/key\u003e\n                \u003cinteger\u003e100\u003c/integer\u003e\n                \u003c!--TODO: Add this flag, if you want to support sharing video into your app--\u003e\n                \u003ckey\u003eNSExtensionActivationSupportsMovieWithMaxCount\u003c/key\u003e\n                \u003cinteger\u003e100\u003c/integer\u003e\n                \u003c!--TODO: Add this flag, if you want to support sharing other files into your app--\u003e\n                \u003c!--Change the integer to however many files you want to be able to share at a time--\u003e\n\t\t\t\t\u003ckey\u003eNSExtensionActivationSupportsFileWithMaxCount\u003c/key\u003e\n\t\t\t\t\u003cinteger\u003e1\u003c/integer\u003e\n            \u003c/dict\u003e\n        \u003c/dict\u003e\n\t\t\u003ckey\u003eNSExtensionMainStoryboard\u003c/key\u003e\n\t\t\u003cstring\u003eMainInterface\u003c/string\u003e\n\t\t\u003ckey\u003eNSExtensionPointIdentifier\u003c/key\u003e\n\t\t\u003cstring\u003ecom.apple.share-services\u003c/string\u003e\n\t\u003c/dict\u003e\n  \u003c/dict\u003e\n\u003c/plist\u003e\n```\n#### 3. Add the following to your [ios/Runner/Info.plist](./example/ios/Runner/Info.plist):\n\n```xml\n...\n\u003ckey\u003eAppGroupId\u003c/key\u003e\n\u003cstring\u003e$(CUSTOM_GROUP_ID)\u003c/string\u003e\n\u003ckey\u003eCFBundleURLTypes\u003c/key\u003e\n\t\u003carray\u003e\n\t\t\u003cdict\u003e\n\t\t\t\u003ckey\u003eCFBundleTypeRole\u003c/key\u003e\n\t\t\t\u003cstring\u003eEditor\u003c/string\u003e\n\t\t\t\u003ckey\u003eCFBundleURLSchemes\u003c/key\u003e\n\t\t\t\u003carray\u003e\n\t\t\t\t\u003cstring\u003eShareMedia-$(PRODUCT_BUNDLE_IDENTIFIER)\u003c/string\u003e\n\t\t\t\u003c/array\u003e\n\t\t\u003c/dict\u003e\n\t\u003c/array\u003e\n\n\u003ckey\u003eNSPhotoLibraryUsageDescription\u003c/key\u003e\n\u003cstring\u003eTo upload photos, please allow permission to access your photo library.\u003c/string\u003e\n...\n```\n\n#### 4. Add the following to your [ios/Runner/Runner.entitlements](./example/ios/Runner/Runner.entitlements):\n\n\n```xml\n....\n    \u003c!--TODO:  Add this tag, if you want support opening urls into your app--\u003e\n    \u003ckey\u003ecom.apple.developer.associated-domains\u003c/key\u003e\n    \u003carray\u003e\n        \u003cstring\u003eapplinks:example.com\u003c/string\u003e\n    \u003c/array\u003e\n....\n```\n\n\n#### 5. Add the following to your [ios/Podfile](./example/ios/Podfile):\n```ruby\n...\ntarget 'Runner' do\n  use_frameworks!\n  use_modular_headers!\n\n  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))\n\n  # Share Extension is name of Extension which you created which is in this case 'Share Extension'\n  target 'Share Extension' do\n    inherit! :search_paths\n  end\nend\n...\n```\n\n#### 6. Add Runner and Share Extension in the same group\n\n* Go to `Signing \u0026 Capabilities` tab and add App Groups capability in **BOTH** Targets: `Runner` and `Share Extension` \n* Add a new container with the name of your choice. For example `group.MyContainer` in the example project its `group.com.kasem.ShareExtention`\n* Add User-defined(`Build Settings -\u003e +`) string `CUSTOM_GROUP_ID` in **BOTH** Targets: `Runner` and `Share Extension` and set value to group id created above. You can use different group ids depends on your flavor schemes\n\n#### 7. Go to Build Phases of your Runner target and move `Embed Foundation Extension` to the top of `Thin Binary`. \n\n\n#### 8. Make your `ShareViewController`  [ios/Share Extension/ShareViewController.swift](./example/ios/Share%20Extension/ShareViewController.swift) inherit from `RSIShareViewController`:\n\n\n```swift\n// If you get no such module 'receive_sharing_intent' error. \n// Go to Build Phases of your Runner target and\n// move `Embed Foundation Extension` to the top of `Thin Binary`. \nimport receive_sharing_intent\n\nclass ShareViewController: RSIShareViewController {\n      \n    // Use this method to return false if you don't want to redirect to host app automatically.\n    // Default is true\n    override func shouldAutoRedirect() -\u003e Bool {\n        return false\n    }\n    \n}\n```\n\n#### Compiling issues and their fixes\n\n* Error: No such module 'receive_sharing_intent'\n  * Fix: Go to Build Phases of your Runner target and move `Embed Foundation Extension` to the top of `Thin Binary`.\n  \n* Error: App does not build after adding Share Extension?\n  * Fix: Check Build Settings of your share extension and remove everything that tries to import Cocoapods from your main project. i.e. remove everything under `Linking/Other Linker Flags` \n\n* You might need to disable bitcode for the extension target\n\n* Error: Invalid Bundle. The bundle at 'Runner.app/Plugins/Sharing Extension.appex' contains disallowed file 'Frameworks'\n    * Fix: https://stackoverflow.com/a/25789145/2061365\n\n\n\n## Full Example\n\n[main.dart](./example/lib/main.dart)\n\n```dart\nimport 'package:flutter/material.dart';\nimport 'dart:async';\n\nimport 'package:receive_sharing_intent/receive_sharing_intent.dart';\n\nvoid main() =\u003e runApp(MyApp());\n\nclass MyApp extends StatefulWidget {\n  @override\n  _MyAppState createState() =\u003e _MyAppState();\n}\n\nclass _MyAppState extends State\u003cMyApp\u003e {\n  late StreamSubscription _intentSub;\n  final _sharedFiles = \u003cSharedMediaFile\u003e[];\n\n  @override\n  void initState() {\n    super.initState();\n\n    // Listen to media sharing coming from outside the app while the app is in the memory.\n    _intentSub = ReceiveSharingIntent.instance.getMediaStream().listen((value) {\n      setState(() {\n        _sharedFiles.clear();\n        _sharedFiles.addAll(value);\n\n        print(_sharedFiles.map((f) =\u003e f.toMap()));\n      });\n    }, onError: (err) {\n      print(\"getIntentDataStream error: $err\");\n    });\n\n    // Get the media sharing coming from outside the app while the app is closed.\n    ReceiveSharingIntent.instance.getInitialMedia().then((value) {\n      setState(() {\n        _sharedFiles.clear();\n        _sharedFiles.addAll(value);\n        print(_sharedFiles.map((f) =\u003e f.toMap()));\n\n        // Tell the library that we are done processing the intent.\n        ReceiveSharingIntent.instance.reset();\n      });\n    });\n  }\n\n  @override\n  void dispose() {\n    _intentSub.cancel();\n    super.dispose();\n  }\n\n  @override\n  Widget build(BuildContext context) {\n    const textStyleBold = const TextStyle(fontWeight: FontWeight.bold);\n    return MaterialApp(\n      home: Scaffold(\n        appBar: AppBar(\n          title: const Text('Plugin example app'),\n        ),\n        body: Center(\n          child: Column(\n            children: \u003cWidget\u003e[\n              Text(\"Shared files:\", style: textStyleBold),\n              Text(_sharedFiles\n                      .map((f) =\u003e f.toMap())\n                      .join(\",\\n****************\\n\")),\n            ],\n          ),\n        ),\n      ),\n    );\n  }\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKasemJaffer%2Freceive_sharing_intent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FKasemJaffer%2Freceive_sharing_intent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKasemJaffer%2Freceive_sharing_intent/lists"}