/expo-share-intent-demo

React Native Expo Share Intent

Primary LanguageJavaScriptApache License 2.0Apache-2.0

Expo Share Intent Demo

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 :

Getting Started

yarn install
yarn prebuild
yarn ios
yarn android

How

For that we use and patch two projects :

we are using patch-package to auto patch, see "patches" directory for details.

iOS Tricks

Thanks to expo-config-plugin-ios-share-extension package we do not need to do manual configuration as described is the original doc

Content Types

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

Android Tricks

For Android build a config plugin has been added (see plugins/withAndroidShareExtension directory) to automate the doc instruction :

Content Types

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" }"

Support

Like my work ? want to say thanks, you can add a star and buy me a coffee to give me strength

Buy Me A Coffee