React Native Share API example to Share TextInput message from App

Share API is used to share any Text message from react native android iOS application to any pre installed and post installed apps in both Android and iOS mobile phone device. The Share API gives us a platform to sharing content between apps. We can share Text message from directly our app to What’s App contacts, Hike Contacts, Groups, SMS, Copy to Clipboard, Share to Google drive, Memo, Bluetooth, Add to OneNote, Email, Gmail, Hangouts, and One Drive and any installed application. So in this tutorial we would going to create a react native app with Share API example to Share TextInput message from App in both Android iOS devices example tutorial.

Contents in this project Share API example to Share TextInput message from App iOS Android example:

1. Import Platform, View, Text, StyleSheet, Share, TextInput and Button component in your project.

2. Create constructor() in your project. Now make a state named as TextInputValueHolder . This state is used to store the TextInput entered value.

3. Create a function named as ShareMessage(). Inside this function we would create the Share API component call its inbuilt method Share.share({ message : Your Message }). We would pass the State as message in here. So any text stored in TextInputValueHolder State shall share as message.

4. Create a Root View in render’s return block.

5. Create 1 TextInput and 1 Button component in Root View. We would store the TextInput inside typed value in State and call the ShareMessage() function on button onPress event.

6. Create Style for Root View and TextInput.

7. Complete source code for App.js File :

Screenshot in Android device :


Share API example to Share TextInput message from App Screenshots in iOS device: