Skip to content

sarsony1/react-native-auto-send-sms-dual-sim

Repository files navigation

react-native-auto-send-sms-dual-sim

A react native library to that will enable users to send SMS from custom SIM from React native. Hasn't published to npm yet.

Installation

npm install react-native-auto-send-sms-dual-sim

Android Permissions that are needed to be added in AndroidManifest.xml

<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.SEND_SMS"/>

Usage

You can refer to the example android for ref.

The API's exposed are shown below

import AutoSendSmsDualSim from "react-native-auto-send-sms-dual-sim";

// Guide for isSimChooserNeeded API 
var hasRequiredPermissions = false;
    const isSimChooserNeeded = await AutoSendSmsDualSim.isSimChooserNeeded(
      (status: string) => {
        if (status === 'Success') {
          hasRequiredPermissions = true;
        }
      }
    );
    if (hasRequiredPermissions) {
      if (isSimChooserNeeded) {
        // Use getPhoneNumberList API
      } else {
        AutoSendSmsDualSim.sendSmsFromSlotIndex(
          null,
          number,
          message,
          callback
        );
      }
    }
    
// Guide for getPhoneNumberList API 

AutoSendSmsDualSim.getPhoneNumberList(
          (phoneNumberJsonString: string) => {
            const phoneNumberJson = JSON.parse(phoneNumberJsonString);
            console.log(`${phoneNumberJson.SIM_0} : ${phoneNumberJson.SIM_1}`);
          }
        );
        
 // Guide for sendSmsFromSlotIndex API
 
 AutoSendSmsDualSim.sendSmsFromSlotIndex(
          simIndex = null, // null if you want to send by default SIM or index 0 or 1 for SIM_1 and SIM_2
          destAddress = number,
          msgBody = message,
          callback = (status, message) => {
          if( status === 'Success'){
          }else{}
          }
        );

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

About

React Native Library for automate send sms from custom sim

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published