rn-sms-retriever
TypeScript icon, indicating that this package has built-in type declarations

1.2.1 • Public • Published

rn-sms-retriever

React Native implementation of Android SMS Retriever. No READ_SMS permisssion is required now, instead we have to use SMS retriever.

For better understanding, please refer this article.

Version 1.2.1 is here :)

  • Fixed - Warning -> Explicitly set requiresMainQueueSetup flag to false.
  • Updated implementation 'com.google.android.gms:play-services-auth:20.3.0'
  • Updated implementation 'com.google.android.gms:play-services-auth-api-phone:18.0.1'

Installation

npm install rn-sms-retriever

Usage

import RnSmsRetriever from 'rn-sms-retriever';

export default function App() {
  React.useEffect(() => {
    let smsListener: undefined | EmitterSubscription;
    async function innerAsync() {
      // get list of available phone numbers
      try {
        const selectedPhone = await RnSmsRetriever.requestPhoneNumber();
        console.log('Selected Phone is : ' + selectedPhone);
      } catch (e) {
        console.log('Get Phone error', e);
      }
      // get App Hash
      const hash = await RnSmsRetriever.getAppHash();
      console.log('Your App Hash is : ' + hash);
      // set Up SMS Listener;
      smsListener = DeviceEventEmitter.addListener(
        RnSmsRetriever.SMS_EVENT,
        (data: any) => {
          console.log(data, 'SMS value');
        }
      );
      // start Retriever;
      await RnSmsRetriever.startSmsRetriever();
    }
    // only to be used with Android
    if (Platform.OS === 'android') innerAsync();
    return () => {
      // remove the listsner on unmount
      smsListener?.remove();
    };
  }, []);
  //....
}

Release Key Hash

If you face any issues with creating Release Key hash follow these steps

Contributing

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

License

MIT

Package Sidebar

Install

npm i rn-sms-retriever

Weekly Downloads

124

Version

1.2.1

License

MIT

Unpacked Size

1.99 MB

Total Files

269

Last publish

Collaborators

  • arpansharma7474