react-native-sms-multi-sim
SendSMS
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
;// you can put any number as Id to identify which message being processSendSMS;
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:
4.1
and supported RN >= v0.29
.
Minimum android version is Installation
npm install react-native-sms-multi-sim --save
Android Setup
1.In your android/settings.gradle
file, make the following additions:
include ':react-native-sms-multi-sim'
project(':react-native-sms-multi-sim').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sms-multi-sim/android/app')
2.In your android/app/build.gradle
file, add the ':react-native-sms-multi-sim' project as a compile-time dependency:
...
dependencies {
...
compile project(':react-native-sms-multi-sim')
}
3.Update the MainApplication.java
file as follow:
... // <--- add here!
4.In your AndroidManifest.xml
file, add a user permission for sending SMS.
<uses-permission android:name="android.permission.SEND_SMS" />
Example
;;; { let SIM1 = 0 let SIM2 = 1 SendSMS; } { return <View style=stylescontainer> <TouchableOpacity style=stylesbutton onPress=thissendSMSFunction> <Text>Send SMS</Text> </TouchableOpacity> </View> ; } const styles = StyleSheet; AppRegistry;