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:

8 Comments

  1. make tutorial for create login app using PHP server please

  2. Can you create articles using Admob in React-Native?
    Thanks!

  3. make tutorial React Native Create CheckBox Using Dynamic JSON MySQL Data, please

  4. Message content is showing empty in Facebook App. But for all other App message content is showing properly. How to share message content to Facebook App from my App?

Leave a Reply

Your email address will not be published. Required fields are marked *