This project demonstrate a fonctionnal share intent in a Expo (React Native) project. It allows to use an expo auto configuration for react-native-receive-sharing-intent package.
This demo works with Expo SDK 48 and is for Android and iOS, using url and text sharing.
More Demo :
- Expo 46 available here (compatible iOS 12.4)
- Expo 47 available here
- Expo 49 available here
yarn install
yarn prebuild
yarn ios
yarn android
For that we use and patch two projects :
- https://github.com/ajith-ab/react-native-receive-sharing-intent
- https://github.com/timedtext/expo-config-plugin-ios-share-extension
we are using patch-package
to auto patch, see "patches" directory for details.
Thanks to expo-config-plugin-ios-share-extension
package we do not need to do manual configuration as described is the original doc
Simply choose content types you need :
"plugins": [
[
"expo-config-plugin-ios-share-extension",
{
"activationRules": {
"NSExtensionActivationSupportsText": true,
"NSExtensionActivationSupportsWebURLWithMaxCount": 1,
"NSExtensionActivationSupportsWebPageWithMaxCount": 1,
"NSExtensionActivationSupportsImageWithMaxCount": 1
}
}
],
],
Option | Values |
---|---|
activationRules | Allow text sharing with "NSExtensionActivationSupportsText": true Url sharing with "NSExtensionActivationSupportsWebURLWithMaxCount": 1 and "NSExtensionActivationSupportsWebPageWithMaxCount": 1 Images sharing with "NSExtensionActivationSupportsImageWithMaxCount": 1 default value: { "NSExtensionActivationSupportsWebURLWithMaxCount": 1, "NSExtensionActivationSupportsWebPageWithMaxCount": 1 }" |
WIP: Corresponding PR for expo-config-plugin-ios-share-extension
For Android build a config plugin has been added (see plugins/withAndroidShareExtension
directory) to automate the doc instruction :
Simply choose content types you need :
"plugins": [
[
"./plugins/withAndroidShareExtension/index",
{
"androidIntentFilters": [
"text/*",
"image/*",
],
}
],
],
Option | Values |
---|---|
androidIntentFilters | array of mime types :"text/*" / "image/*" / "*/*" default value: ["text/*"] (text and url) |
androidMainActivityAttributes | default value: { "android:launchMode": "singleTask" }" |
Like my work ? want to say thanks, you can add a star and buy me a coffee to give me strength