Author - StudySection Post Views - 944 views

How To Receive Shared Intent In The React-Native Application

Nowadays, a share feature plays an important role in mobile applications. If you want to share something from your application to another or within the application then the share option should be available in your Intent in the application.

In this article, I am going to discuss how we can receive the content i.e, photos, videos, text, or URL in your react-native application. For this functionality, react-native provides a react-native-receive-sharing-intent plugin for it. It is a module that empowers React Native applications to get sharing photographs, recordings, text, URLs, or some other document types from another application.

It also supports both android and iOS platforms.

Intent Sharing Installation

$ npm install react-native-receive-sharing-intent --save

$ cd ios && pod install

Example usage

import ReceiveSharingIntent from 'react-native-receive-sharing-intent';
//call below function in your app.js componentDidMount()
// To get All Received Urls
ReceiveSharingIntent.getReceivedFiles(files => {
// files returns as JSON Array example
//[{ filePath: null, text: null, weblink: null, mimeType: null, contentUri: null, fileName: null, extension: null }] },
(error) =>{
// To clear Intents you can call it in componentWillUnmount()

With the above example output, you can recognize the shared data and handle it according to your requirement in your react-native application.

If you have skills in PHP programming and you want to enhance your career in this field, a PHP certification from StudySection can help you reach your desired goals. Both beginner level and expert level PHP Certification Exams are offered by StudySection along with other programming certification exams.

Leave a Reply

Your email address will not be published.