Receive Shared Files in your React Native App

Nov 23, 2022

While building our react native app, we may come up with the feature to receive shared file from other app to our app, and using that file we further build the feature according to our requirement.

Now point how to setup our react native app to talk with other apps and receive data.

In this blog we gonna walk through on building this feature.

I am assuming you already setup with your react native project and if not use the below command to setup your first react native project.

To build receive shared file feature we gonna use react-native-receive-sharing-intent npm package, this package will help us to use native modules to access shared files inside our app.
CD inside your  AwesomeProject folder and install this package.

Before accessing this package inside our react native files, let us do some configuration for android and ios separately inside our app. Follow the below steps to do it.


Go to AwesomeProject/android/app/src/main/manifest.xml

Add the below code inside your manifest.xml file inside manifest tag.

The above code helps to add filter on what type of files you want to recieve in your android app. Now go to AwesomeProject/android/app/src/main/java/com/AwesomeProject/, and copy the below code inside your

We done with Android let’s do some configuration for IOS.


For ios go inside AwesomeProject/ios/AwesomeProject/info.plist and open info.plist file And the below code inside this file inside dict tag

Now go this folder AwesomeProject/ios/AwesomeProject/AppDelegate.m and open AppDelegate.m, copy below code inside this file

Now we want to setup a share extension in our IOS app so it will be visible in share sheet of other apps.
Open your AwesomeProject/ios/AwesomeProject.xcworkspace in xcode
Now to create share extension inside our app inside 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"

Now open AwesomeProject/ios/<Your Share Extension Name>/info.plist, and add below code inside the info.plist

Now go to AwesomeProject/ios/<Your Share Extension Name>/ShareViewController.swift and copy paste below code inside your file.

NOTE :- change the `hostAppBundleIdentifier` value to your main host app bundle identifier (example in my case: `com.awesomeproject` ) in this `ShareViewController.swift`.

Coding in our React native app.

Now we done with the setup for our android and ios configuration, let’s do some coding part and use react-native-receive-sharing-intent in our project.

Add the below code in your app.js or index.js file in your react native project

Re run your project go to any other app and share data to your app, you can also see your app name inside other app share sheet, select your app and hopefully you can see that file related data inside your logger.

Raghvendra Rathore

I am from India and currently working at JTC. I like to develop full-stack web applications, like to learn about new tech, and share my knowledge with the community. Apart from that, I love chess too.

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.