├── example ├── .watchmanconfig ├── .gitattributes ├── app.json ├── .eslintrc.js ├── babel.config.js ├── android │ ├── app │ │ ├── src │ │ │ ├── main │ │ │ │ ├── res │ │ │ │ │ ├── values │ │ │ │ │ │ ├── strings.xml │ │ │ │ │ │ └── styles.xml │ │ │ │ │ ├── mipmap-hdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ │ ├── mipmap-mdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ │ ├── mipmap-xhdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ │ └── mipmap-xxxhdpi │ │ │ │ │ │ ├── ic_launcher.png │ │ │ │ │ │ └── ic_launcher_round.png │ │ │ │ ├── java │ │ │ │ │ └── com │ │ │ │ │ │ └── github │ │ │ │ │ │ └── meedaan │ │ │ │ │ │ ├── MainActivity.java │ │ │ │ │ │ └── MainApplication.java │ │ │ │ └── AndroidManifest.xml │ │ │ └── debug │ │ │ │ ├── AndroidManifest.xml │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── github │ │ │ │ └── meedaan │ │ │ │ └── ReactNativeFlipper.java │ │ ├── debug.keystore │ │ ├── proguard-rules.pro │ │ ├── build_defs.bzl │ │ ├── _BUCK │ │ └── build.gradle │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── settings.gradle │ ├── build.gradle │ ├── gradle.properties │ ├── gradlew.bat │ └── gradlew ├── ios │ ├── Test │ │ ├── Images.xcassets │ │ │ ├── Contents.json │ │ │ └── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ ├── AppDelegate.h │ │ ├── main.m │ │ ├── Test.entitlements │ │ ├── Info.plist │ │ ├── AppDelegate.m │ │ └── LaunchScreen.storyboard │ ├── ShareExtension │ │ ├── ShareExtension-Bridging-Header.h │ │ ├── ShareExtension.entitlements │ │ ├── Base.lproj │ │ │ └── MainInterface.storyboard │ │ └── Info.plist │ ├── Test.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── TestTests │ │ ├── Info.plist │ │ └── TestTests.m │ ├── Test-tvOSTests │ │ └── Info.plist │ ├── Podfile │ ├── Test-tvOS │ │ └── Info.plist │ ├── Test.xcodeproj │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ ├── Test.xcscheme │ │ │ └── Test-tvOS.xcscheme │ └── Podfile.lock ├── .buckconfig ├── .prettierrc.js ├── index.share.js ├── index.js ├── __tests__ │ └── App-test.js ├── README.md ├── package.json ├── metro.config.js ├── .gitignore ├── .flowconfig ├── App.js └── Share.js ├── .npmignore ├── screenshots ├── Xcode-01.png ├── Xcode-02.png ├── Xcode-03.png ├── Xcode-04.png ├── Xcode-05.png ├── Xcode-06.png ├── Xcode-07.png ├── Xcode-08.png ├── iOS_menu.png ├── iOS_view.png ├── android-app.png ├── android-menu.png ├── ios-share-view.gif └── CustomReactShareView.gif ├── android ├── src │ └── main │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── com │ │ └── meedan │ │ ├── ShareMenuPackage.java │ │ └── ShareMenuModule.java └── build.gradle ├── ios ├── ShareMenu-Bridging-Header.h ├── Modules │ ├── ShareMenu.m │ ├── ShareMenuReactView.m │ ├── ShareMenu.swift │ └── ShareMenuReactView.swift ├── ShareMenuManager.h ├── ReactShareViewDelegate.swift ├── ShareMenuMessenger.swift ├── Extensions │ ├── NSItemProvider+Extensions.swift │ └── URL+Extensions.swift ├── ShareMenuManager.m ├── ReactShareViewController.swift ├── Constants.swift ├── ShareMenu.xcodeproj │ └── project.pbxproj └── ShareViewController.swift ├── package.json ├── RNShareMenu.podspec ├── .gitignore ├── LICENSE ├── index.js ├── ANDROID_INSTRUCTIONS.md ├── API_DOCS.md ├── SHARE_EXTENSION_VIEW.md ├── README.md └── IOS_INSTRUCTIONS.md /example/.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | example 2 | screenshots 3 | -------------------------------------------------------------------------------- /example/.gitattributes: -------------------------------------------------------------------------------- 1 | *.pbxproj -text 2 | -------------------------------------------------------------------------------- /example/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example", 3 | "displayName": "React Native Share Menu Example" 4 | } 5 | -------------------------------------------------------------------------------- /example/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | extends: '@react-native-community', 4 | }; 5 | -------------------------------------------------------------------------------- /example/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ['module:metro-react-native-babel-preset'], 3 | }; 4 | -------------------------------------------------------------------------------- /screenshots/Xcode-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrXyfir/react-native-share-menu/HEAD/screenshots/Xcode-01.png -------------------------------------------------------------------------------- /screenshots/Xcode-02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrXyfir/react-native-share-menu/HEAD/screenshots/Xcode-02.png -------------------------------------------------------------------------------- /screenshots/Xcode-03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrXyfir/react-native-share-menu/HEAD/screenshots/Xcode-03.png -------------------------------------------------------------------------------- /screenshots/Xcode-04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrXyfir/react-native-share-menu/HEAD/screenshots/Xcode-04.png -------------------------------------------------------------------------------- /screenshots/Xcode-05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrXyfir/react-native-share-menu/HEAD/screenshots/Xcode-05.png -------------------------------------------------------------------------------- /screenshots/Xcode-06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrXyfir/react-native-share-menu/HEAD/screenshots/Xcode-06.png -------------------------------------------------------------------------------- /screenshots/Xcode-07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrXyfir/react-native-share-menu/HEAD/screenshots/Xcode-07.png -------------------------------------------------------------------------------- /screenshots/Xcode-08.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrXyfir/react-native-share-menu/HEAD/screenshots/Xcode-08.png -------------------------------------------------------------------------------- /screenshots/iOS_menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrXyfir/react-native-share-menu/HEAD/screenshots/iOS_menu.png -------------------------------------------------------------------------------- /screenshots/iOS_view.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrXyfir/react-native-share-menu/HEAD/screenshots/iOS_view.png -------------------------------------------------------------------------------- /screenshots/android-app.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrXyfir/react-native-share-menu/HEAD/screenshots/android-app.png -------------------------------------------------------------------------------- /screenshots/android-menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrXyfir/react-native-share-menu/HEAD/screenshots/android-menu.png -------------------------------------------------------------------------------- /screenshots/ios-share-view.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrXyfir/react-native-share-menu/HEAD/screenshots/ios-share-view.gif -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | example 3 | 4 | -------------------------------------------------------------------------------- /example/ios/Test/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /example/android/app/debug.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrXyfir/react-native-share-menu/HEAD/example/android/app/debug.keystore -------------------------------------------------------------------------------- /screenshots/CustomReactShareView.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrXyfir/react-native-share-menu/HEAD/screenshots/CustomReactShareView.gif -------------------------------------------------------------------------------- /example/.buckconfig: -------------------------------------------------------------------------------- 1 | 2 | [android] 3 | target = Google Inc.:Google APIs:23 4 | 5 | [maven_repositories] 6 | central = https://repo1.maven.org/maven2 7 | -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /example/.prettierrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | bracketSpacing: false, 3 | jsxBracketSameLine: true, 4 | singleQuote: true, 5 | trailingComma: 'all', 6 | }; 7 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrXyfir/react-native-share-menu/HEAD/example/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrXyfir/react-native-share-menu/HEAD/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrXyfir/react-native-share-menu/HEAD/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrXyfir/react-native-share-menu/HEAD/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrXyfir/react-native-share-menu/HEAD/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrXyfir/react-native-share-menu/HEAD/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrXyfir/react-native-share-menu/HEAD/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrXyfir/react-native-share-menu/HEAD/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrXyfir/react-native-share-menu/HEAD/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrXyfir/react-native-share-menu/HEAD/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MrXyfir/react-native-share-menu/HEAD/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /ios/ShareMenu-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #ifndef ShareMenu_Bridging_Header_h 2 | #define ShareMenu_Bridging_Header_h 3 | 4 | #import 5 | #import 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /example/index.share.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @format 3 | */ 4 | 5 | import {AppRegistry} from 'react-native'; 6 | import Share from './Share'; 7 | 8 | AppRegistry.registerComponent('ShareMenuModuleComponent', () => Share); 9 | -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'example' 2 | apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) 3 | include ':app' 4 | -------------------------------------------------------------------------------- /example/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @format 3 | */ 4 | 5 | import {AppRegistry} from 'react-native'; 6 | import App from './App'; 7 | import {name as appName} from './app.json'; 8 | 9 | AppRegistry.registerComponent(appName, () => App); 10 | -------------------------------------------------------------------------------- /example/ios/Test/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface AppDelegate : UIResponder 5 | 6 | @property (nonatomic, strong) UIWindow *window; 7 | 8 | @end 9 | -------------------------------------------------------------------------------- /ios/Modules/ShareMenu.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface RCT_EXTERN_MODULE(ShareMenu, RCTEventEmitter) 5 | 6 | RCT_EXTERN_METHOD(getSharedText:(RCTResponseSenderBlock)callback) 7 | 8 | @end 9 | -------------------------------------------------------------------------------- /example/ios/Test/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | #import "AppDelegate.h" 4 | 5 | int main(int argc, char * argv[]) { 6 | @autoreleasepool { 7 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.2-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /example/ios/ShareExtension/ShareExtension-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import 4 | #import 5 | #if SUPPORT_UNIMODULES 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /example/ios/Test.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/ios/Test.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /example/__tests__/App-test.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @format 3 | */ 4 | 5 | import 'react-native'; 6 | import React from 'react'; 7 | import App from '../App'; 8 | 9 | // Note: test renderer must be required after react-native. 10 | import renderer from 'react-test-renderer'; 11 | 12 | it('renders correctly', () => { 13 | renderer.create(); 14 | }); 15 | -------------------------------------------------------------------------------- /ios/ShareMenuManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // ShareMenuManager.h 3 | // react-native-share-menu 4 | // 5 | // Created by Gustavo Parreira on 26/07/2020. 6 | // 7 | 8 | @interface ShareMenuManager : NSObject 9 | 10 | + (BOOL)application:(UIApplication *)app 11 | openURL:(NSURL *)url 12 | options:(NSDictionary *)options; 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /ios/ReactShareViewDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ReactShareViewDelegate.swift 3 | // RNShareMenu 4 | // 5 | // Created by Gustavo Parreira on 29/07/2020. 6 | // 7 | 8 | public protocol ReactShareViewDelegate { 9 | func loadExtensionContext() -> NSExtensionContext 10 | 11 | func openApp() 12 | 13 | func continueInApp(with item: NSExtensionItem, and extraData: [String:Any]?) 14 | } 15 | -------------------------------------------------------------------------------- /example/ios/Test/Test.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.application-groups 6 | 7 | group.com.github.meedaan.ReactNativeShareMenuExample 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/ios/ShareExtension/ShareExtension.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.application-groups 6 | 7 | group.com.github.meedaan.ReactNativeShareMenuExample 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /ios/Modules/ShareMenuReactView.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface RCT_EXTERN_MODULE(ShareMenuReactView, NSObject) 4 | 5 | RCT_EXTERN_METHOD(data:(RCTPromiseResolveBlock)resolver reject:(RCTPromiseRejectBlock)rejecter) 6 | 7 | RCT_EXTERN_METHOD(dismissExtension:(NSString *)error) 8 | 9 | RCT_EXTERN_METHOD(openApp) 10 | 11 | RCT_EXTERN_METHOD(continueInApp:(NSDictionary *)extraData) 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/android/app/src/main/java/com/github/meedaan/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.github.meedaan; 2 | 3 | import com.facebook.react.ReactActivity; 4 | 5 | public class MainActivity extends ReactActivity { 6 | 7 | /** 8 | * Returns the name of the main component registered from JavaScript. This is used to schedule 9 | * rendering of the component. 10 | */ 11 | @Override 12 | protected String getMainComponentName() { 13 | return "example"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /example/android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 29 5 | buildToolsVersion "29.0.2" 6 | 7 | defaultConfig { 8 | minSdkVersion 16 9 | targetSdkVersion 29 10 | versionCode 1 11 | versionName "1.0" 12 | ndk { 13 | abiFilters "armeabi-v7a", "x86" 14 | } 15 | } 16 | lintOptions { 17 | warning 'InvalidPackage' 18 | } 19 | } 20 | 21 | dependencies { 22 | //noinspection GradleDynamicVersion 23 | implementation 'com.facebook.react:react-native:+' 24 | } 25 | -------------------------------------------------------------------------------- /ios/ShareMenuMessenger.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ShareMenuMessenger.swift 3 | // RNShareMenu 4 | // 5 | // This class handles all messages from Obj-C to the main ShareMenu.swift file 6 | // 7 | // Created by Gustavo Parreira on 27/07/2020. 8 | // 9 | 10 | @objc(ShareMenuMessenger) 11 | open class ShareMenuMessenger: NSObject { 12 | @objc public static func share( 13 | application app: UIApplication, 14 | openUrl url: URL, 15 | options: [UIApplication.OpenURLOptionsKey : Any] 16 | ) { 17 | ShareMenu.messageShare(application: app, openUrl: url, options: options) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # example 2 | 3 | First install all dependencies by running `yarn install`. 4 | 5 | To run the app on iOS: 6 | 7 | - Run `cd ios/ && pod install` 8 | - Run `yarn react-native run-ios`, or 9 | - Open `example/ios/Test.xcworkspace` in Xcode and hit the "Run" button 10 | 11 | To run the app on Android: 12 | 13 | - Have an Android emulator running (quickest way to get started), or a device connected 14 | - `yarn react-native run-android` 15 | - You may need to run `yarn start` (more information about this [here](https://facebook.github.io/react-native/docs/getting-started.html#troubleshooting-run)) 16 | -------------------------------------------------------------------------------- /ios/Extensions/NSItemProvider+Extensions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NSItemProvider+Extensions.swift 3 | // RNShareMenu 4 | // 5 | // Created by Gustavo Parreira on 29/07/2020. 6 | // 7 | 8 | import MobileCoreServices 9 | 10 | public extension NSItemProvider { 11 | var isText: Bool { 12 | return hasItemConformingToTypeIdentifier(kUTTypeText as String) 13 | } 14 | 15 | var isURL: Bool { 16 | return hasItemConformingToTypeIdentifier(kUTTypeURL as String) && !isFileURL 17 | } 18 | 19 | var isFileURL: Bool { 20 | return hasItemConformingToTypeIdentifier(kUTTypeFileURL as String) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /ios/ShareMenuManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // ShareMenuManager.m 3 | // react-native-share-menu 4 | // 5 | // Created by Gustavo Parreira on 26/07/2020. 6 | // 7 | 8 | #import "ShareMenuManager.h" 9 | #import "RNShareMenu-Swift.h" 10 | 11 | #import 12 | 13 | @implementation ShareMenuManager 14 | 15 | + (BOOL)application:(UIApplication *)app 16 | openURL:(NSURL *)url 17 | options:(NSDictionary *)options 18 | { 19 | [ShareMenuMessenger shareWithApplication:app openUrl:url options:options]; 20 | return [RCTLinkingManager application:app openURL:url options:options]; 21 | } 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /example/android/app/build_defs.bzl: -------------------------------------------------------------------------------- 1 | """Helper definitions to glob .aar and .jar targets""" 2 | 3 | def create_aar_targets(aarfiles): 4 | for aarfile in aarfiles: 5 | name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")] 6 | lib_deps.append(":" + name) 7 | android_prebuilt_aar( 8 | name = name, 9 | aar = aarfile, 10 | ) 11 | 12 | def create_jar_targets(jarfiles): 13 | for jarfile in jarfiles: 14 | name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")] 15 | lib_deps.append(":" + name) 16 | prebuilt_jar( 17 | name = name, 18 | binary_jar = jarfile, 19 | ) 20 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-native-share-menu", 3 | "description": "Add your app as a target for sharing from other apps and write iOS Share Extensions in React Native.", 4 | "version": "5.0.3", 5 | "repository": { 6 | "type": "git", 7 | "url": "git+https://github.com/MrXyfir/react-native-share-menu.git" 8 | }, 9 | "keywords": [ 10 | "react-component", 11 | "react-native", 12 | "android", 13 | "ios", 14 | "share", 15 | "share-extension", 16 | "custom-view" 17 | ], 18 | "author": { 19 | "name": "Meedan", 20 | "email": "hello@meedan.com" 21 | }, 22 | "homepage": "https://github.com/MrXyfir/react-native-share-menu", 23 | "license": "MIT", 24 | "readmeFilename": "README.md" 25 | } 26 | -------------------------------------------------------------------------------- /ios/Extensions/URL+Extensions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // URL+Extensions.swift 3 | // RNShareMenu 4 | // 5 | // Created by Gustavo Parreira on 29/07/2020. 6 | // 7 | 8 | import MobileCoreServices 9 | 10 | public extension URL { 11 | func extractMimeType() -> String { 12 | let fileExtension: CFString = pathExtension as CFString 13 | guard let extUTI = UTTypeCreatePreferredIdentifierForTag( 14 | kUTTagClassFilenameExtension, 15 | fileExtension, 16 | nil 17 | )?.takeUnretainedValue() else { return "" } 18 | 19 | guard let mimeUTI = UTTypeCopyPreferredTagWithClass(extUTI, kUTTagClassMIMEType) 20 | else { return "" } 21 | 22 | return mimeUTI.takeUnretainedValue() as String 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /RNShareMenu.podspec: -------------------------------------------------------------------------------- 1 | require "json" 2 | 3 | package = JSON.parse(File.read(File.join(__dir__, "package.json"))) 4 | 5 | Pod::Spec.new do |s| 6 | s.name = "RNShareMenu" 7 | s.version = package["version"] 8 | s.summary = package["description"] 9 | s.homepage = package["homepage"] 10 | s.license = package["license"] 11 | s.authors = package["author"] 12 | 13 | s.platforms = { :ios => "12.0" } 14 | s.source = { :git => "https://github.com/meedan/react-native-share-menu.git", :tag => "#{s.version}" } 15 | s.swift_version = "5.2" 16 | 17 | 18 | s.source_files = "ios/**/*.{h,m,mm,swift}" 19 | s.exclude_files = [ 20 | "ios/ShareViewController.swift", 21 | "ios/ReactShareViewController.swift" 22 | ] 23 | 24 | 25 | s.dependency "React" 26 | end 27 | -------------------------------------------------------------------------------- /example/ios/TestTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example", 3 | "version": "0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "android": "react-native run-android", 7 | "ios": "react-native run-ios", 8 | "start": "react-native start", 9 | "test": "jest", 10 | "lint": "eslint ." 11 | }, 12 | "dependencies": { 13 | "react": "16.13.1", 14 | "react-native": "0.63.2", 15 | "react-native-share-menu": "link:.." 16 | }, 17 | "devDependencies": { 18 | "@babel/core": "^7.8.4", 19 | "@babel/runtime": "^7.8.4", 20 | "@react-native-community/eslint-config": "^1.1.0", 21 | "babel-jest": "^25.1.0", 22 | "eslint": "^6.5.1", 23 | "jest": "^25.1.0", 24 | "metro-react-native-babel-preset": "^0.59.0", 25 | "react-test-renderer": "16.13.1" 26 | }, 27 | "jest": { 28 | "preset": "react-native" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /example/ios/Test-tvOSTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /android/src/main/java/com/meedan/ShareMenuPackage.java: -------------------------------------------------------------------------------- 1 | package com.meedan; 2 | 3 | import androidx.annotation.NonNull; 4 | 5 | import java.util.List; 6 | import java.util.ArrayList; 7 | import java.util.Collections; 8 | 9 | import com.facebook.react.ReactPackage; 10 | import com.facebook.react.bridge.NativeModule; 11 | import com.facebook.react.bridge.ReactApplicationContext; 12 | import com.facebook.react.uimanager.ViewManager; 13 | 14 | public class ShareMenuPackage implements ReactPackage { 15 | @NonNull 16 | @Override 17 | public List createNativeModules(@NonNull ReactApplicationContext reactContext) { 18 | List modules = new ArrayList<>(); 19 | modules.add(new ShareMenuModule(reactContext)); 20 | return modules; 21 | } 22 | 23 | @NonNull 24 | @Override 25 | public List createViewManagers(@NonNull ReactApplicationContext reactContext) { 26 | return Collections.emptyList(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /example/metro.config.js: -------------------------------------------------------------------------------- 1 | 2 | // metro.config.js 3 | // 4 | // with multiple workarounds for this issue with symlinks: 5 | // https://github.com/facebook/metro/issues/1 6 | // 7 | // with thanks to @johnryan () 8 | // for the pointers to multiple workaround solutions here: 9 | // https://github.com/facebook/metro/issues/1#issuecomment-541642857 10 | // 11 | // see also this discussion: 12 | // https://github.com/brodybits/create-react-native-module/issues/232 13 | 14 | const path = require('path') 15 | 16 | module.exports = { 17 | // workaround for an issue with symlinks encountered starting with 18 | // metro@0.55 / React Native 0.61 19 | // (not needed with React Native 0.60 / metro@0.54) 20 | resolver: { 21 | extraNodeModules: new Proxy( 22 | {}, 23 | { get: (_, name) => path.resolve('.', 'node_modules', name) } 24 | ) 25 | }, 26 | 27 | // quick workaround for another issue with symlinks 28 | watchFolders: ['.', '..'] 29 | } 30 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | 24 | # Android/IntelliJ 25 | # 26 | build/ 27 | .idea 28 | .gradle 29 | local.properties 30 | *.iml 31 | 32 | # node.js 33 | # 34 | node_modules/ 35 | npm-debug.log 36 | yarn-error.log 37 | 38 | # BUCK 39 | buck-out/ 40 | \.buckd/ 41 | *.keystore 42 | !debug.keystore 43 | 44 | # fastlane 45 | # 46 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 47 | # screenshots whenever they are needed. 48 | # For more information about the recommended setup visit: 49 | # https://docs.fastlane.tools/best-practices/source-control/ 50 | 51 | */fastlane/report.xml 52 | */fastlane/Preview.html 53 | */fastlane/screenshots 54 | 55 | # Bundle artifact 56 | *.jsbundle 57 | 58 | # CocoaPods 59 | /ios/Pods/ 60 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | project.xcworkspace 24 | 25 | # node.js 26 | # 27 | node_modules/ 28 | npm-debug.log 29 | 30 | # Logs 31 | logs 32 | *.log 33 | 34 | # Runtime data 35 | pids 36 | *.pid 37 | *.seed 38 | 39 | # Directory for instrumented libs generated by jscoverage/JSCover 40 | lib-cov 41 | 42 | # Coverage directory used by tools like istanbul 43 | coverage 44 | 45 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 46 | .grunt 47 | 48 | # node-waf configuration 49 | .lock-wscript 50 | 51 | # Compiled binary addons (http://nodejs.org/api/addons.html) 52 | build/Release 53 | 54 | # Dependency directory 55 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git 56 | node_modules 57 | build/ 58 | 59 | # IDE Files 60 | .idea/ 61 | -------------------------------------------------------------------------------- /example/ios/Test/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "scale" : "2x", 6 | "size" : "20x20" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "scale" : "3x", 11 | "size" : "20x20" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "scale" : "2x", 16 | "size" : "29x29" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "scale" : "3x", 21 | "size" : "29x29" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "scale" : "2x", 26 | "size" : "40x40" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "scale" : "3x", 31 | "size" : "40x40" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "scale" : "2x", 36 | "size" : "60x60" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "scale" : "3x", 41 | "size" : "60x60" 42 | }, 43 | { 44 | "idiom" : "ios-marketing", 45 | "scale" : "1x", 46 | "size" : "1024x1024" 47 | } 48 | ], 49 | "info" : { 50 | "author" : "xcode", 51 | "version" : 1 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Caio Almeida 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /example/android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | ext { 5 | buildToolsVersion = "29.0.2" 6 | minSdkVersion = 16 7 | compileSdkVersion = 29 8 | targetSdkVersion = 29 9 | } 10 | repositories { 11 | google() 12 | jcenter() 13 | } 14 | dependencies { 15 | classpath("com.android.tools.build:gradle:3.5.3") 16 | // NOTE: Do not place your application dependencies here; they belong 17 | // in the individual module build.gradle files 18 | } 19 | } 20 | 21 | allprojects { 22 | repositories { 23 | mavenLocal() 24 | maven { 25 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 26 | url("$rootDir/../node_modules/react-native/android") 27 | } 28 | maven { 29 | // Android JSC is installed from npm 30 | url("$rootDir/../node_modules/jsc-android/dist") 31 | } 32 | 33 | google() 34 | jcenter() 35 | maven { url 'https://www.jitpack.io' } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | import { NativeModules, NativeEventEmitter } from "react-native"; 2 | 3 | const { ShareMenu } = NativeModules; 4 | 5 | const EventEmitter = new NativeEventEmitter(ShareMenu); 6 | 7 | const NEW_SHARE_EVENT_NAME = "NewShareEvent"; 8 | 9 | export const ShareMenuReactView = { 10 | dismissExtension(error = null) { 11 | NativeModules.ShareMenuReactView.dismissExtension(error); 12 | }, 13 | openApp() { 14 | NativeModules.ShareMenuReactView.openApp(); 15 | }, 16 | continueInApp(extraData = null) { 17 | NativeModules.ShareMenuReactView.continueInApp(extraData); 18 | }, 19 | data() { 20 | return NativeModules.ShareMenuReactView.data(); 21 | }, 22 | }; 23 | 24 | export default { 25 | /** 26 | * @deprecated Use `getInitialShare` instead. This is here for backwards compatibility. 27 | */ 28 | getSharedText(callback) { 29 | this.getInitialShare(callback); 30 | }, 31 | getInitialShare(callback) { 32 | ShareMenu.getSharedText(callback); 33 | }, 34 | addNewShareListener(callback) { 35 | const subscription = EventEmitter.addListener( 36 | NEW_SHARE_EVENT_NAME, 37 | callback 38 | ); 39 | 40 | return subscription; 41 | }, 42 | }; 43 | -------------------------------------------------------------------------------- /example/ios/Podfile: -------------------------------------------------------------------------------- 1 | require_relative '../node_modules/react-native/scripts/react_native_pods' 2 | require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' 3 | 4 | platform :ios, '10.0' 5 | 6 | target 'Test' do 7 | config = use_native_modules! 8 | 9 | use_react_native!(:path => config["reactNativePath"]) 10 | 11 | target 'TestTests' do 12 | inherit! :complete 13 | # Pods for testing 14 | end 15 | 16 | # Enables Flipper. 17 | # 18 | # Note that if you have use_frameworks! enabled, Flipper will not work and 19 | # you should disable these next few lines. 20 | use_flipper! 21 | post_install do |installer| 22 | flipper_post_install(installer) 23 | installer.pods_project.targets.each do |target| 24 | target.build_configurations.each do |config| 25 | config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'NO' 26 | end 27 | end 28 | end 29 | end 30 | 31 | target 'ShareExtension' do 32 | use_react_native! 33 | 34 | pod 'RNShareMenu', :path => '../..' 35 | end 36 | 37 | target 'Test-tvOS' do 38 | # Pods for Test-tvOS 39 | 40 | target 'Test-tvOSTests' do 41 | inherit! :search_paths 42 | # Pods for testing 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | # AndroidX package structure to make it clearer which packages are bundled with the 21 | # Android operating system, and which are packaged with your app's APK 22 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 23 | android.useAndroidX=true 24 | # Automatically convert third-party libraries to use AndroidX 25 | android.enableJetifier=true 26 | 27 | # Version of flipper SDK to use with React Native 28 | FLIPPER_VERSION=0.37.0 29 | -------------------------------------------------------------------------------- /ios/ReactShareViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ReactShareViewController.swift 3 | // RNShareMenu 4 | // 5 | // DO NOT EDIT THIS FILE. IT WILL BE OVERRIDEN BY NPM OR YARN. 6 | // 7 | // Created by Gustavo Parreira on 29/07/2020. 8 | // 9 | 10 | import RNShareMenu 11 | 12 | class ReactShareViewController: ShareViewController, RCTBridgeDelegate, ReactShareViewDelegate { 13 | 14 | func sourceURL(for bridge: RCTBridge!) -> URL! { 15 | #if DEBUG 16 | return RCTBundleURLProvider.sharedSettings()? 17 | .jsBundleURL(forBundleRoot: "index.share", fallbackResource: nil) 18 | #else 19 | return Bundle.main.url(forResource: "main", withExtension: "jsbundle") 20 | #endif 21 | } 22 | 23 | override func viewDidLoad() { 24 | super.viewDidLoad() 25 | let bridge: RCTBridge! = RCTBridge(delegate: self, launchOptions: nil) 26 | let rootView = RCTRootView( 27 | bridge: bridge, 28 | moduleName: "ShareMenuModuleComponent", 29 | initialProperties: nil 30 | ) 31 | self.view = rootView 32 | ShareMenuReactView.attachViewDelegate(self) 33 | } 34 | 35 | override func viewDidDisappear(_ animated: Bool) { 36 | cancel() 37 | ShareMenuReactView.detachViewDelegate() 38 | } 39 | 40 | func loadExtensionContext() -> NSExtensionContext { 41 | return extensionContext! 42 | } 43 | 44 | func openApp() { 45 | self.openHostApp() 46 | } 47 | 48 | func continueInApp(with item: NSExtensionItem, and extraData: [String:Any]?) { 49 | handlePost(item, extraData: extraData) 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /example/android/app/_BUCK: -------------------------------------------------------------------------------- 1 | # To learn about Buck see [Docs](https://buckbuild.com/). 2 | # To run your application with Buck: 3 | # - install Buck 4 | # - `npm start` - to start the packager 5 | # - `cd android` 6 | # - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"` 7 | # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck 8 | # - `buck install -r android/app` - compile, install and run application 9 | # 10 | 11 | load(":build_defs.bzl", "create_aar_targets", "create_jar_targets") 12 | 13 | lib_deps = [] 14 | 15 | create_aar_targets(glob(["libs/*.aar"])) 16 | 17 | create_jar_targets(glob(["libs/*.jar"])) 18 | 19 | android_library( 20 | name = "all-libs", 21 | exported_deps = lib_deps, 22 | ) 23 | 24 | android_library( 25 | name = "app-code", 26 | srcs = glob([ 27 | "src/main/java/**/*.java", 28 | ]), 29 | deps = [ 30 | ":all-libs", 31 | ":build_config", 32 | ":res", 33 | ], 34 | ) 35 | 36 | android_build_config( 37 | name = "build_config", 38 | package = "com.github.meedaan", 39 | ) 40 | 41 | android_resource( 42 | name = "res", 43 | package = "com.github.meedaan", 44 | res = "src/main/res", 45 | ) 46 | 47 | android_binary( 48 | name = "app", 49 | keystore = "//android/keystores:debug", 50 | manifest = "src/main/AndroidManifest.xml", 51 | package_type = "debug", 52 | deps = [ 53 | ":app-code", 54 | ], 55 | ) 56 | -------------------------------------------------------------------------------- /ANDROID_INSTRUCTIONS.md: -------------------------------------------------------------------------------- 1 | # Android Installation 2 | 3 |
4 | Manual Install 5 | 6 | - In `android/settings.gradle` 7 | 8 | ```gradle 9 | ... 10 | include ':react-native-share-menu', ':app' 11 | project(':react-native-share-menu').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-share-menu/android') 12 | ``` 13 | 14 | - In `android/app/build.gradle` 15 | 16 | ```gradle 17 | ... 18 | dependencies { 19 | ... 20 | compile project(':react-native-share-menu') 21 | } 22 | ``` 23 | 24 | - Register module (in MainApplication.java) 25 | 26 | ```java 27 | import com.meedan.ShareMenuPackage; // <--- import 28 | 29 | public class MainApplication extends Application implements ReactApplication { 30 | ...... 31 | @Override 32 | protected List getPackages() { 33 | return Arrays.asList( 34 | new MainReactPackage(), 35 | new ShareMenuPackage() // <------ add here 36 | ); 37 | } 38 | ...... 39 | 40 | } 41 | ``` 42 | 43 |
44 | 45 | ## Add Intent Filter 46 | 47 | - In `android/app/src/main/AndroidManifest.xml` in the `` tag: 48 | 49 | ```xml 50 | 53 | ... 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | ``` 63 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 13 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /example/ios/Test-tvOS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | NSAppTransportSecurity 26 | 27 | NSExceptionDomains 28 | 29 | localhost 30 | 31 | NSExceptionAllowsInsecureHTTPLoads 32 | 33 | 34 | 35 | 36 | NSLocationWhenInUseUsageDescription 37 | 38 | UILaunchStoryboardName 39 | LaunchScreen 40 | UIRequiredDeviceCapabilities 41 | 42 | armv7 43 | 44 | UISupportedInterfaceOrientations 45 | 46 | UIInterfaceOrientationPortrait 47 | UIInterfaceOrientationLandscapeLeft 48 | UIInterfaceOrientationLandscapeRight 49 | 50 | UIViewControllerBasedStatusBarAppearance 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /example/ios/ShareExtension/Base.lproj/MainInterface.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /example/ios/TestTests/TestTests.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | #import 5 | #import 6 | 7 | #define TIMEOUT_SECONDS 600 8 | #define TEXT_TO_LOOK_FOR @"Welcome to React" 9 | 10 | @interface TestTests : XCTestCase 11 | 12 | @end 13 | 14 | @implementation TestTests 15 | 16 | - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test 17 | { 18 | if (test(view)) { 19 | return YES; 20 | } 21 | for (UIView *subview in [view subviews]) { 22 | if ([self findSubviewInView:subview matching:test]) { 23 | return YES; 24 | } 25 | } 26 | return NO; 27 | } 28 | 29 | - (void)testRendersWelcomeScreen 30 | { 31 | UIViewController *vc = [[[RCTSharedApplication() delegate] window] rootViewController]; 32 | NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS]; 33 | BOOL foundElement = NO; 34 | 35 | __block NSString *redboxError = nil; 36 | #ifdef DEBUG 37 | RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) { 38 | if (level >= RCTLogLevelError) { 39 | redboxError = message; 40 | } 41 | }); 42 | #endif 43 | 44 | while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) { 45 | [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 46 | [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 47 | 48 | foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) { 49 | if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) { 50 | return YES; 51 | } 52 | return NO; 53 | }]; 54 | } 55 | 56 | #ifdef DEBUG 57 | RCTSetLogFunction(RCTDefaultLogFunction); 58 | #endif 59 | 60 | XCTAssertNil(redboxError, @"RedBox error: %@", redboxError); 61 | XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS); 62 | } 63 | 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /example/ios/Test/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | Test 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleURLTypes 24 | 25 | 26 | CFBundleTypeRole 27 | Editor 28 | CFBundleURLSchemes 29 | 30 | ShareMenuModule 31 | 32 | 33 | 34 | CFBundleVersion 35 | 1 36 | LSRequiresIPhoneOS 37 | 38 | NSAppTransportSecurity 39 | 40 | NSAllowsArbitraryLoads 41 | 42 | NSExceptionDomains 43 | 44 | localhost 45 | 46 | NSExceptionAllowsInsecureHTTPLoads 47 | 48 | 49 | 50 | 51 | NSLocationWhenInUseUsageDescription 52 | 53 | UILaunchStoryboardName 54 | LaunchScreen 55 | UIRequiredDeviceCapabilities 56 | 57 | armv7 58 | 59 | UISupportedInterfaceOrientations 60 | 61 | UIInterfaceOrientationPortrait 62 | UIInterfaceOrientationLandscapeLeft 63 | UIInterfaceOrientationLandscapeRight 64 | 65 | UIViewControllerBasedStatusBarAppearance 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /example/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | ; We fork some components by platform 3 | .*/*[.]android.js 4 | 5 | ; Ignore "BUCK" generated dirs 6 | /\.buckd/ 7 | 8 | ; Ignore polyfills 9 | node_modules/react-native/Libraries/polyfills/.* 10 | 11 | ; These should not be required directly 12 | ; require from fbjs/lib instead: require('fbjs/lib/warning') 13 | node_modules/warning/.* 14 | 15 | ; Flow doesn't support platforms 16 | .*/Libraries/Utilities/LoadingView.js 17 | 18 | [untyped] 19 | .*/node_modules/@react-native-community/cli/.*/.* 20 | 21 | [include] 22 | 23 | [libs] 24 | node_modules/react-native/interface.js 25 | node_modules/react-native/flow/ 26 | 27 | [options] 28 | emoji=true 29 | 30 | esproposal.optional_chaining=enable 31 | esproposal.nullish_coalescing=enable 32 | 33 | module.file_ext=.js 34 | module.file_ext=.json 35 | module.file_ext=.ios.js 36 | 37 | munge_underscores=true 38 | 39 | module.name_mapper='^react-native/\(.*\)$' -> '/node_modules/react-native/\1' 40 | module.name_mapper='^@?[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '/node_modules/react-native/Libraries/Image/RelativeImageStub' 41 | 42 | suppress_type=$FlowIssue 43 | suppress_type=$FlowFixMe 44 | suppress_type=$FlowFixMeProps 45 | suppress_type=$FlowFixMeState 46 | 47 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\) 48 | suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+ 49 | suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError 50 | 51 | [lints] 52 | sketchy-null-number=warn 53 | sketchy-null-mixed=warn 54 | sketchy-number=warn 55 | untyped-type-import=warn 56 | nonstrict-import=warn 57 | deprecated-type=warn 58 | unsafe-getters-setters=warn 59 | unnecessary-invariant=warn 60 | signature-verification-failure=warn 61 | deprecated-utility=error 62 | 63 | [strict] 64 | deprecated-type 65 | nonstrict-import 66 | sketchy-null 67 | unclear-type 68 | unsafe-getters-setters 69 | untyped-import 70 | untyped-type-import 71 | 72 | [version] 73 | ^0.122.0 74 | -------------------------------------------------------------------------------- /ios/Constants.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Constants.swift 3 | // RNShareMenu 4 | // 5 | // Created by Gustavo Parreira on 29/07/2020. 6 | // 7 | 8 | // MARK: Error Codes 9 | public let DISMISS_SHARE_EXTENSION_WITH_ERROR_CODE = 1 10 | 11 | // MARK: Error Messages 12 | 13 | public let NO_URL_TYPES_ERROR_MESSAGE = "You have not defined CFBundleURLTypes in your Info.plist" 14 | public let NO_URL_SCHEMES_ERROR_MESSAGE = "You have not defined CFBundleURLSchemes in your Info.plist" 15 | public let NO_SCHEME_ERROR_MESSAGE = "You have not defined a scheme under CFBundleURLSchemes in your Info.plist" 16 | public let NO_APP_GROUP_ERROR = "Failed to get App Group User Defaults. Did you set up an App Group on your App and Share Extension?" 17 | public let NO_INFO_PLIST_INDENTIFIER_ERROR = "You haven't defined \(HOST_APP_IDENTIFIER_INFO_PLIST_KEY) in your Share Extension's Info.plist" 18 | public let NO_INFO_PLIST_URL_SCHEME_ERROR = "You haven't defined \(HOST_URL_SCHEME_INFO_PLIST_KEY) in your Share Extension's Info.plist" 19 | public let COULD_NOT_FIND_STRING_ERROR = "Couldn't find string" 20 | public let COULD_NOT_FIND_URL_ERROR = "Couldn't find url" 21 | public let COULD_NOT_FIND_IMG_ERROR = "Couldn't find image" 22 | public let COULD_NOT_PARSE_IMG_ERROR = "Couldn't parse image" 23 | public let COULD_NOT_SAVE_FILE_ERROR = "Couldn't save file on disk" 24 | public let NO_EXTENSION_CONTEXT_ERROR = "No extension context attached" 25 | public let NO_DELEGATE_ERROR = "No ReactShareViewDelegate attached" 26 | public let COULD_NOT_FIND_ITEM_ERROR = "Couldn't find item attached to this share" 27 | 28 | // MARK: Keys 29 | 30 | public let USER_DEFAULTS_KEY = "ShareMenuUserDefaults" 31 | public let USER_DEFAULTS_EXTRA_DATA_KEY = "ShareMenuUserDefaultsExtraData" 32 | public let URL_SCHEME_INFO_PLIST_KEY = "AppURLScheme" 33 | public let HOST_APP_IDENTIFIER_INFO_PLIST_KEY = "HostAppBundleIdentifier" 34 | public let HOST_URL_SCHEME_INFO_PLIST_KEY = "HostAppURLScheme" 35 | 36 | public let REACT_SHARE_VIEW_BACKGROUND_COLOR_KEY = "ReactShareViewBackgroundColor" 37 | public let COLOR_RED_KEY = "Red" 38 | public let COLOR_GREEN_KEY = "Green" 39 | public let COLOR_BLUE_KEY = "Blue" 40 | public let COLOR_ALPHA_KEY = "Alpha" 41 | public let COLOR_TRANSPARENT_KEY = "Transparent" 42 | 43 | public let MIME_TYPE_KEY = "mimeType" 44 | public let DATA_KEY = "data" 45 | public let EXTRA_DATA_KEY = "extraData" 46 | 47 | // MARK: Events 48 | 49 | public let NEW_SHARE_EVENT = "NewShareEvent" 50 | -------------------------------------------------------------------------------- /example/ios/ShareExtension/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | ShareExtension 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleVersion 22 | 1 23 | HostAppBundleIdentifier 24 | com.github.meedaan.ReactNativeShareMenuExample 25 | HostAppURLScheme 26 | ShareMenuModule:// 27 | NSExtension 28 | 29 | NSExtensionAttributes 30 | 31 | NSExtensionActivationRule 32 | 33 | NSExtensionActivationSupportsFileWithMaxCount 34 | 10 35 | NSExtensionActivationSupportsMovieWithMaxCount 36 | 10 37 | NSExtensionActivationSupportsImageWithMaxCount 38 | 10 39 | NSExtensionActivationSupportsText 40 | 41 | NSExtensionActivationSupportsWebURLWithMaxCount 42 | 10 43 | 44 | 45 | NSExtensionMainStoryboard 46 | MainInterface 47 | NSExtensionPointIdentifier 48 | com.apple.share-services 49 | 50 | ReactShareViewBackgroundColor 51 | 52 | Red 53 | 1 54 | Green 55 | 1 56 | Blue 57 | 1 58 | Alpha 59 | 1 60 | Transparent 61 | 62 | 63 | NSAppTransportSecurity 64 | 65 | NSAllowsArbitraryLoads 66 | 67 | NSExceptionDomains 68 | 69 | localhost 70 | 71 | NSExceptionAllowsInsecureHTTPLoads 72 | 73 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /example/App.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Sample React Native App 3 | * https://github.com/facebook/react-native 4 | * 5 | * @format 6 | * @flow strict-local 7 | */ 8 | import React, {useState, useEffect, useCallback} from 'react'; 9 | import {StyleSheet, Text, View, Image} from 'react-native'; 10 | import ShareMenu from 'react-native-share-menu'; 11 | 12 | type SharedItem = { 13 | mimeType: string, 14 | data: string, 15 | }; 16 | 17 | const App: () => React$Node = () => { 18 | const [sharedData, setSharedData] = useState(''); 19 | const [sharedMimeType, setSharedMimeType] = useState(''); 20 | const [sharedExtraData, setSharedExtraData] = useState(null); 21 | 22 | const handleShare = useCallback((item: ?SharedItem) => { 23 | if (!item) { 24 | return; 25 | } 26 | 27 | const {mimeType, data, extraData} = item; 28 | 29 | setSharedData(data); 30 | setSharedExtraData(extraData); 31 | setSharedMimeType(mimeType); 32 | }, []); 33 | 34 | useEffect(() => { 35 | ShareMenu.getInitialShare(handleShare); 36 | }, []); 37 | 38 | useEffect(() => { 39 | const listener = ShareMenu.addNewShareListener(handleShare); 40 | 41 | return () => { 42 | listener.remove(); 43 | }; 44 | }, []); 45 | 46 | return ( 47 | 48 | React Native Share Menu 49 | Shared type: {sharedMimeType} 50 | 51 | Shared text: {sharedMimeType === 'text/plain' ? sharedData : ''} 52 | 53 | Shared image: 54 | {sharedMimeType.startsWith('image/') && ( 55 | 60 | )} 61 | 62 | Shared file:{' '} 63 | {sharedMimeType !== 'text/plain' && !sharedMimeType.startsWith('image/') 64 | ? sharedData 65 | : ''} 66 | 67 | 68 | Extra data: {sharedExtraData ? JSON.stringify(sharedExtraData) : ''} 69 | 70 | 71 | ); 72 | }; 73 | 74 | const styles = StyleSheet.create({ 75 | container: { 76 | flex: 1, 77 | justifyContent: 'center', 78 | alignItems: 'center', 79 | backgroundColor: '#F5FCFF', 80 | }, 81 | welcome: { 82 | fontSize: 20, 83 | textAlign: 'center', 84 | margin: 10, 85 | }, 86 | instructions: { 87 | textAlign: 'center', 88 | color: '#333333', 89 | marginBottom: 5, 90 | }, 91 | image: { 92 | width: '100%', 93 | height: 200, 94 | }, 95 | }); 96 | 97 | export default App; 98 | -------------------------------------------------------------------------------- /example/ios/Test/AppDelegate.m: -------------------------------------------------------------------------------- 1 | #import "AppDelegate.h" 2 | 3 | #import 4 | #import 5 | #import 6 | #import 7 | 8 | #ifdef FB_SONARKIT_ENABLED 9 | #import 10 | #import 11 | #import 12 | #import 13 | #import 14 | #import 15 | 16 | #import 17 | 18 | static void InitializeFlipper(UIApplication *application) { 19 | FlipperClient *client = [FlipperClient sharedClient]; 20 | SKDescriptorMapper *layoutDescriptorMapper = [[SKDescriptorMapper alloc] initWithDefaults]; 21 | [client addPlugin:[[FlipperKitLayoutPlugin alloc] initWithRootNode:application withDescriptorMapper:layoutDescriptorMapper]]; 22 | [client addPlugin:[[FKUserDefaultsPlugin alloc] initWithSuiteName:nil]]; 23 | [client addPlugin:[FlipperKitReactPlugin new]]; 24 | [client addPlugin:[[FlipperKitNetworkPlugin alloc] initWithNetworkAdapter:[SKIOSNetworkAdapter new]]]; 25 | [client start]; 26 | } 27 | #endif 28 | 29 | @implementation AppDelegate 30 | 31 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 32 | { 33 | #ifdef FB_SONARKIT_ENABLED 34 | InitializeFlipper(application); 35 | #endif 36 | 37 | RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions]; 38 | RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge 39 | moduleName:@"example" 40 | initialProperties:nil]; 41 | 42 | rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1]; 43 | 44 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 45 | UIViewController *rootViewController = [UIViewController new]; 46 | rootViewController.view = rootView; 47 | self.window.rootViewController = rootViewController; 48 | [self.window makeKeyAndVisible]; 49 | return YES; 50 | } 51 | 52 | - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge 53 | { 54 | #if DEBUG 55 | return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil]; 56 | #else 57 | return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; 58 | #endif 59 | } 60 | 61 | - (BOOL)application:(UIApplication *)app 62 | openURL:(NSURL *)url 63 | options:(NSDictionary *)options 64 | { 65 | return [ShareMenuManager application:app openURL:url options:options]; 66 | } 67 | 68 | @end 69 | -------------------------------------------------------------------------------- /example/android/app/src/main/java/com/github/meedaan/MainApplication.java: -------------------------------------------------------------------------------- 1 | package com.github.meedaan; 2 | 3 | import android.app.Application; 4 | import android.content.Context; 5 | import com.facebook.react.PackageList; 6 | import com.facebook.react.ReactApplication; 7 | import com.facebook.react.ReactInstanceManager; 8 | import com.facebook.react.ReactNativeHost; 9 | import com.facebook.react.ReactPackage; 10 | import com.facebook.soloader.SoLoader; 11 | import java.lang.reflect.InvocationTargetException; 12 | import java.util.List; 13 | 14 | public class MainApplication extends Application implements ReactApplication { 15 | 16 | private final ReactNativeHost mReactNativeHost = 17 | new ReactNativeHost(this) { 18 | @Override 19 | public boolean getUseDeveloperSupport() { 20 | return BuildConfig.DEBUG; 21 | } 22 | 23 | @Override 24 | protected List getPackages() { 25 | @SuppressWarnings("UnnecessaryLocalVariable") 26 | List packages = new PackageList(this).getPackages(); 27 | // Packages that cannot be autolinked yet can be added manually here, for example: 28 | // packages.add(new MyReactNativePackage()); 29 | return packages; 30 | } 31 | 32 | @Override 33 | protected String getJSMainModuleName() { 34 | return "index"; 35 | } 36 | }; 37 | 38 | @Override 39 | public ReactNativeHost getReactNativeHost() { 40 | return mReactNativeHost; 41 | } 42 | 43 | @Override 44 | public void onCreate() { 45 | super.onCreate(); 46 | SoLoader.init(this, /* native exopackage */ false); 47 | initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); 48 | } 49 | 50 | /** 51 | * Loads Flipper in React Native templates. Call this in the onCreate method with something like 52 | * initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); 53 | * 54 | * @param context 55 | * @param reactInstanceManager 56 | */ 57 | private static void initializeFlipper( 58 | Context context, ReactInstanceManager reactInstanceManager) { 59 | if (BuildConfig.DEBUG) { 60 | try { 61 | /* 62 | We use reflection here to pick up the class that initializes Flipper, 63 | since Flipper library is not available in release mode 64 | */ 65 | Class aClass = Class.forName("com.github.meedaan.ReactNativeFlipper"); 66 | aClass 67 | .getMethod("initializeFlipper", Context.class, ReactInstanceManager.class) 68 | .invoke(null, context, reactInstanceManager); 69 | } catch (ClassNotFoundException e) { 70 | e.printStackTrace(); 71 | } catch (NoSuchMethodException e) { 72 | e.printStackTrace(); 73 | } catch (IllegalAccessException e) { 74 | e.printStackTrace(); 75 | } catch (InvocationTargetException e) { 76 | e.printStackTrace(); 77 | } 78 | } 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /API_DOCS.md: -------------------------------------------------------------------------------- 1 | # API Docs 2 | 3 | ## ShareMenu 4 | 5 | ### `getInitialShare(callback: ShareCallback) : void` 6 | 7 | #### Gets the shared item the app was opened with, if any. 8 | 9 | #### Where `ShareCallback` 10 | 11 | `(share: ShareData?) => void` 12 | 13 | #### and `ShareData` 14 | 15 | | Result | Type | Description | 16 | | --------- | ------ | ----------------------------------------------------------------------------------------- | 17 | | mimeType | String | The mime type of the shared data | 18 | | data | String | Either the shared text, or the location of the shared file | 19 | | extraData | Object | Can be null. Any optional extra data your Share Extension React View opened the app with. | 20 | 21 | ### `addNewShareListener(callback: ShareCallback) : ShareListener` 22 | 23 | #### Adds a listener for receiving shared data from other apps. Call `listener.remove()` to remove it on unmount. 24 | 25 | #### Where `ShareCallback` 26 | 27 | `(share: ShareData?) => void` 28 | 29 | #### and `ShareData` 30 | 31 | | Result | Type | Description | 32 | | --------- | ------ | ----------------------------------------------------------------------------------------- | 33 | | mimeType | String | The mime type of the shared data | 34 | | data | String | Either the shared text, or the location of the shared file | 35 | | extraData | Object | Can be null. Any optional extra data your Share Extension React View opened the app with. | 36 | 37 | #### and `ShareListener` 38 | 39 | | Method | Params | Description | 40 | | -------- | ------ | ---------------------------------------- | 41 | | remove() | None | Removes a previously registered listener | 42 | 43 | ## ShareMenuReactView 44 | 45 | ### `dismissExtension(error?: String) : void` 46 | 47 | #### Dismisses the open Share Extension. Send an error message as a parameter to notify the system that the share action was canceled. 48 | 49 | ### `openApp() : void` 50 | 51 | #### Opens the App from the Share Extension. 52 | 53 | ### `continueInApp(extraData?: Object) : void` 54 | 55 | #### Defers the handling of this share action to the main App. You can send any object as a parameter if you need more context to handle the share in-app. 56 | 57 | ### `data() : Promise` 58 | 59 | #### Gets the shared data this Share Extension was opened with. 60 | 61 | #### Where `ShareData` 62 | 63 | | Result | Type | Description | 64 | | -------- | ------ | ---------------------------------------------------------- | 65 | | mimeType | String | The mime type of the shared data | 66 | | data | String | Either the shared text, or the location of the shared file | 67 | -------------------------------------------------------------------------------- /example/Share.js: -------------------------------------------------------------------------------- 1 | import React, {useEffect, useState} from 'react'; 2 | import {View, Text, Pressable, Image, StyleSheet} from 'react-native'; 3 | import {ShareMenuReactView} from 'react-native-share-menu'; 4 | 5 | const Button = ({onPress, title, style}) => ( 6 | 7 | {title} 8 | 9 | ) 10 | 11 | const Share = () => { 12 | const [sharedData, setSharedData] = useState(''); 13 | const [sharedMimeType, setSharedMimeType] = useState(''); 14 | const [sending, setSending] = useState(false); 15 | 16 | useEffect(() => { 17 | ShareMenuReactView.data().then(({mimeType, data}) => { 18 | setSharedData(data); 19 | setSharedMimeType(mimeType); 20 | }); 21 | }, []); 22 | 23 | return ( 24 | 25 | 26 |