react-native-share-menu
Advanced tools
Comparing version 4.1.0 to 4.1.1
{ | ||
"name": "react-native-share-menu", | ||
"description": "Adds the app to share menu, so it can be launched from share menu and receive data from other apps", | ||
"version": "4.1.0", | ||
"version": "4.1.1", | ||
"repository": { | ||
@@ -6,0 +6,0 @@ "type": "git", |
103
README.md
@@ -111,2 +111,51 @@ # react-native-share-menu | ||
Make these changes to your Podfile: | ||
```diff | ||
target '<PROJECT_NAME>' do | ||
config = use_native_modules! | ||
use_react_native!(:path => config["reactNativePath"]) | ||
target '<PROJECT_NAME>Tests' do | ||
inherit! :complete | ||
# Pods for testing | ||
end | ||
# Enables Flipper. | ||
# | ||
# Note that if you have use_frameworks! enabled, Flipper will not work and | ||
# you should disable these next few lines. | ||
use_flipper! | ||
post_install do |installer| | ||
flipper_post_install(installer) | ||
+ installer.pods_project.targets.each do |target| | ||
+ target.build_configurations.each do |config| | ||
+ config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'NO' | ||
+ end | ||
+ end | ||
end | ||
end | ||
+target '<SHARE_EXTENSION_NAME>' do | ||
+ config = use_native_modules! | ||
+ | ||
+ use_react_native!(:path => config["reactNativePath"]) | ||
+end | ||
``` | ||
Run `pod install` in your `ios/` directory. | ||
<details> | ||
<summary>If you're using React Native < 0.62</summary> | ||
<br> | ||
Create a bridging header by right clicking on your project folder: | ||
- Selecting Add Files to "PROJECT_NAME" | ||
- Choose Swift | ||
- Make sure the selected target is your main app target | ||
- Create file and say yes to creating a Bridging Header file | ||
- Delete everything in the Swift file, but keep the file around | ||
</details> | ||
Create an App Group to be able to share data between your extension and your app. To do so, go to your app target's settings, go to `Signing & Capabilities`, press `+ Capability` and select `App Groups` | ||
@@ -189,39 +238,2 @@ | ||
Make these changes to your Podfile: | ||
```diff | ||
target '<PROJECT_NAME>' do | ||
config = use_native_modules! | ||
use_react_native!(:path => config["reactNativePath"]) | ||
target '<PROJECT_NAME>Tests' do | ||
inherit! :complete | ||
# Pods for testing | ||
end | ||
# Enables Flipper. | ||
# | ||
# Note that if you have use_frameworks! enabled, Flipper will not work and | ||
# you should disable these next few lines. | ||
use_flipper! | ||
post_install do |installer| | ||
flipper_post_install(installer) | ||
+ installer.pods_project.targets.each do |target| | ||
+ target.build_configurations.each do |config| | ||
+ config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'NO' | ||
+ end | ||
+ end | ||
end | ||
end | ||
target '<SHARE_EXTENSION_NAME>' do | ||
config = use_native_modules! | ||
use_react_native!(:path => config["reactNativePath"]) | ||
end | ||
``` | ||
Run `pod install` in your `ios/` directory. | ||
Right click on your Share Extension folder, and choose `Add Files to "ProjectName"` | ||
@@ -279,3 +291,6 @@ | ||
```javascript | ||
AppRegistry.registerComponent('ShareMenuModuleComponent', () => MyShareComponent); | ||
AppRegistry.registerComponent( | ||
"ShareMenuModuleComponent", | ||
() => MyShareComponent | ||
); | ||
``` | ||
@@ -359,7 +374,7 @@ | ||
const Share = () => { | ||
const [sharedData, setSharedData] = useState(''); | ||
const [sharedMimeType, setSharedMimeType] = useState(''); | ||
const [sharedData, setSharedData] = useState(""); | ||
const [sharedMimeType, setSharedMimeType] = useState(""); | ||
useEffect(() => { | ||
ShareMenuReactView.data().then(({mimeType, data}) => { | ||
ShareMenuReactView.data().then(({ mimeType, data }) => { | ||
setSharedData(data); | ||
@@ -400,7 +415,9 @@ setSharedMimeType(mimeType); | ||
onPress={() => { | ||
ShareMenuReactView.continueInApp({hello: "from the other side"}); | ||
ShareMenuReactView.continueInApp({ hello: "from the other side" }); | ||
}} | ||
/> | ||
{sharedMimeType === "text/plain" && <Text>{sharedData}</Text>} | ||
{sharedMimeType.startsWith("image/") && <Image source={{uri: sharedData}} />} | ||
{sharedMimeType.startsWith("image/") && ( | ||
<Image source={{ uri: sharedData }} /> | ||
)} | ||
</View> | ||
@@ -407,0 +424,0 @@ ); |
85627
441