# react-native-receive-sharing-intent
A React Native plugin that enables React Native apps to receive sharing photos, videos, text, urls or any other file types from another app.
Also, supports iOS Share extension and launching the host app automatically. Check the provided example for more info.
## Demo
| Android | Ios |
| :---: | :---: |
| <img height="400" src="https://raw.githubusercontent.com/ajith-ab/react-native-receive-sharing-intent/master/doc/android.gif" />| <img height="400" src="https://raw.githubusercontent.com/ajith-ab/react-native-receive-sharing-intent/master/doc/ios.gif" /> |
## Installation
#### Npm
```bash
$ npm install react-native-receive-sharing-intent --save
```
#### Yarn
```bash
$ yarn add react-native-receive-sharing-intent
```
#### ios
```bash
$ cd ios && pod install
```
### Mostly automatic installation less than React Native `0.60.0`
`$ react-native link react-native-receive-sharing-intent`
Note: `Ios and Android on Debbuging time not working at sometimes while App is Closed`
### Android
` <Project_folder>/android/app/src/main/manifest.xml `
```xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example">
....
<!--TODO Add this Line -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<application .... >
<activity
....
android:launchMode="singleTask"> <!--TODO IMPORTANT.set launchMode -> singleTask Recommended -->
.....
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!--TODO: Add this filter, if you want support opening urls into your app-->
<data
android:scheme="https"
android:host="example.com"
android:pathPrefix="/invite"/>
</intent-filter>
<!--TODO: Add this filter, if you want to support sharing text into your app-->
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/*" />
</intent-filter>
<!--TODO: Add this filter, if you want to support sharing images into your app-->
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
<!--TODO: Add this filter, if you want to support sharing videos into your app-->
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="video/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="video/*" />
</intent-filter>
<!--TODO: Add this filter, if you want to support sharing any type of files-->
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="*/*" />
</intent-filter>
.....
</activity>
</application>
</manifest>
```
- On MainActivity on your react-native app
` <Project_folder>/android/app/src/main/java/com/YOUR_APP/MainActivity.java` :
```java
// on top of your file
import android.content.Intent;
...
public class MainActivity extends ReactActivity {
...
// on your MainActivity Class body
@Override
public void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
}
...
}
```
### Ios
`<project_folder>/ios/<project_name>/info.plist`
```xml
<plist version="1.0">
<dict>
.....
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>ShareMedia</string> <!-- share url protocol (must be unique to your app, suggest using your apple bundle id) -->
</array>
</dict>
<dict/>
</array>
<key>NSPhotoLibraryUsageDescription</key>
<string>
To upload photos, please allow permission to access your photo library.
</string>
....
</dict>
</plist>
```
`<project_folder>/ios/<project_name>/AppDelegate.m`
```objectivec
....
#import <React/RCTLinkingManager.h> // Add this Line in Header of file
....
@implementation AppDelegate
...
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
{
return [RCTLinkingManager application:application openURL:url options:options];
}
@end
```
`<project_folder>/ios/<your project name>/<your project name>.entitlements`
```xml
....
<!--TODO: Add this tag, if you want support opening urls into your app-->
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:example.com</string>
</array>
....
```
#### Create Share Extension
- Using xcode, go to File/New/Target and Choose "Share Extension"
- Give it a name you want to show on while Sharing i.e. i Choose "Example Share"
`<project_folder>/ios/<Your Share Extension Name>/info.plist`
```xml
<plist version="1.0">
<dict>
...
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>PHSupportedMediaTypes</key>
<array>
<!--TODO: Add this flag, if you want to support sharing video into your app-->
<string>Video</string>
<!--TODO: Add this flag, if you want to support sharing images into your app-->
<string>Image</string>
</array>
<key>NSExtensionActivationRule</key>
<dict>
<!--TODO: Add this flag, if you want to support sharing text into your app-->
<key>NSExtensionActivationSupportsText</key>
<true/>
<!--TODO: Add this tag, if you want to support sharing urls into your app-->
<key>NSExtensionActivationSupportsWebURLWithMaxCount</key>
<integer>1</integer>
<!--TODO: Add this flag, if you want to support sharing images into your app-->
<key>NSExtensionActivationSupportsImageWithMaxCount</key>
<integer>100</integer>
<!--TODO: Add this flag, if you want to support sharing video into your app-->
<key>NSExtensionActivationSupportsMovieWithMaxCount</key>
<integer>100</integer>
<!--TODO: Add this flag, if you want to support sharing other files into your app-->
<!--Change the integer to however many files you want to be able to share at a time-->
<key>NSExtensionActivationSupportsFileWithMaxCount</key>
<integer>
没有合适的资源?快使用搜索试试~ 我知道了~
react-native-receive-sharing-intent:一个React Native插件,使React Nati...
共105个文件
png:12个
js:9个
plist:7个
需积分: 31 1 下载量 198 浏览量
2021-04-01
01:15:05
上传
评论
收藏 5.85MB ZIP 举报
温馨提示
React本机接收共享意图 一个React Native插件,使React Native应用程序能够从另一个应用程序接收共享的照片,视频,文本,URL或任何其他文件类型。 此外,还支持iOS Share扩展并自动启动主机应用程序。 查看提供的示例以获取更多信息。 演示版 安卓 爱欧斯 安装 Npm $ npm install react-native-receive-sharing-intent --save 纱 $ yarn add react-native-receive-sharing-intent ios $ cd ios && pod install 自动安装通常少于React Native 0.60.0 $ react-native link react-native-receive-sharing-intent 注意: Ios and Android on Debb
资源详情
资源评论
资源推荐
收起资源包目录
react-native-receive-sharing-intent:一个React Native插件,使React Native应用程序能够从另一个应用程序接收共享的照片,视频,文本,URL或任何其他文件类型 (105个子文件)
gradlew.bat 3KB
gradlew.bat 2KB
BUCK 1KB
.buckconfig 114B
build_defs.bzl 602B
.classpath 352B
.classpath 352B
example.entitlements 410B
Examples share.entitlements 300B
.flowconfig 2KB
ios.gif 3.64MB
android.gif 1.9MB
.gitattributes 16B
.gitignore 813B
.gitignore 413B
build.gradle 9KB
build.gradle 5KB
build.gradle 1003B
settings.gradle 191B
gradlew 6KB
gradlew 5KB
ReceiveSharingIntent-Bridging-Header.h 206B
AppDelegate.h 196B
gradle-wrapper.jar 54KB
gradle-wrapper.jar 53KB
ReceiveSharingIntentHelper.java 7KB
ReactNativeFlipper.java 3KB
MainApplication.java 3KB
ReceiveSharingIntentModule.java 2KB
ReceiveSharingIntentPackage.java 787B
MainActivity.java 512B
mimeType.js 21KB
index.js 3KB
App.js 1017B
metro.config.js 300B
App-test.js 266B
index.js 183B
.prettierrc.js 120B
babel.config.js 77B
.eslintrc.js 74B
package.json 2KB
package.json 727B
Contents.json 585B
Contents.json 63B
app.json 51B
debug.keystore 2KB
LICENSE 1KB
yarn.lock 297KB
Podfile.lock 16KB
AppDelegate.m 2KB
exampleTests.m 2KB
ReceiveSharingIntent-Bridge.m 495B
main.m 200B
README.md 23KB
README.md 662B
.npmignore 13B
project.pbxproj 48KB
project.pbxproj 11KB
Info.plist 2KB
Info.plist 1KB
Info.plist 1KB
Info.plist 765B
Info.plist 733B
IDEWorkspaceChecks.plist 238B
IDEWorkspaceChecks.plist 238B
app group2.png 64KB
app group1.png 64KB
ic_launcher_round.png 15KB
ic_launcher_round.png 10KB
ic_launcher.png 9KB
ic_launcher_round.png 7KB
ic_launcher.png 6KB
ic_launcher_round.png 5KB
ic_launcher.png 4KB
ic_launcher.png 3KB
ic_launcher_round.png 3KB
ic_launcher.png 2KB
Podfile 5KB
react-native-receive-sharing-intent.podspec 953B
org.eclipse.buildship.core.prefs 386B
org.eclipse.buildship.core.prefs 383B
org.eclipse.buildship.core.prefs 383B
proguard-rules.pro 435B
.project 599B
.project 591B
.project 433B
gradle.properties 1KB
gradle-wrapper.properties 232B
gradle-wrapper.properties 202B
MainInterface.storyboard 2KB
MainInterface.storyboard 2KB
ShareViewController.swift 12KB
ReceiveSharingIntent.swift 7KB
index.d.ts 626B
.watchmanconfig 2B
example.xcscheme 3KB
example-tvOS.xcscheme 3KB
contents.xcworkspacedata 225B
contents.xcworkspacedata 166B
LaunchScreen.xib 4KB
共 105 条
- 1
- 2
深夜里呕吐的鱼公子
- 粉丝: 20
- 资源: 4721
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0