react-native-sms-x
A react-native api to send SMS messages. It works only for android. This component used android native api to send sms and response a callback to react-native. This react-native component doesn't link to the mobile default messenger view. It will programmatically send the message to a phone number which is provided as a parameter and will response a callback with a string indicating message was sent or failure or no service.
usage
Response msg string will be one of the following:
- "SMS sent" - for successful message
- "Generic failure" - for general failure
- "No service" - for no mobile operator service
- "Radio off" - for no mobile signal
- "Null PDU" - for no PDU
Note:
Minimum android version is 4.1
and supported RN >= v0.29
.
Installation
npm install react-native-sms-x --save
Android Setup
1.In your android/settings.gradle
file, make the following additions:
include ':react-native-sms-x'
project(':react-native-sms-x').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sms-x/android/app')
2.In your android/app/build.gradle
file, add the ':react-native-sms-x' project as a compile-time dependency:
...
dependencies {
...
compile project(':react-native-sms-x')
}
3.Update the MainApplication.java
file as follow:
4.In your AndroidManifest.xml
file, add a user permission for sending SMS.
<uses-permission android:name="android.permission.SEND_SMS" />
Example