andreyvital / react-native-android-sms-listener

Allows you to listen for incoming SMS messages using React Native
MIT License
358 stars 99 forks source link

Google play store reject my app because of permission #42

Closed msbt2019 closed 4 years ago

msbt2019 commented 5 years ago

This is the message google send me :

Based on our review, we found your app’s expressed user experience did not match your declared core functionality {Default SMS handler (and any other core functionality usage while default handler)}. Please remove these permissions from your app.

Default handler capability was listed on your declaration form, but your app does not appear to have default handler capability. Please submit a revised declaration form.

This is my source code : componentDidMount() { if(Platform.OS === 'android') { this._requestReadSmsPermission() } }

_requestReadSmsPermission = async () => { try { const result = await PermissionsAndroid.requestMultiple([PermissionsAndroid.PERMISSIONS.RECEIVE_SMS, PermissionsAndroid.PERMISSIONS.READ_SMS])

  if (result['android.permission.RECEIVE_SMS'] && result['android.permission.READ_SMS'] === PermissionsAndroid.RESULTS.GRANTED) {
    this.smsListener = SmsListener.addListener(message => {
      if(message.originatingAddress == "MYNAME") {
        let verificationCodeRegex = /: ([\d]{6})/

        if (verificationCodeRegex.test(message.body)) {
          let verificationCode = message.body.match(verificationCodeRegex)[1]

          if(codeVerification == verificationCode) {
            alert('Succes verification')
          }
        }
      }
    })
  }
} catch (err) {
  console.warn(err)
}

}

And this is my androidmanifest :

<uses-permission android:name="android.permission.READ_SMS" />
kush11 commented 5 years ago

give permission in android manifest:

and the component (screen ) on which you are using use PermissionsAndroid from react-native

componentDidMount() { this.readSmsPermission(); }

async readSmsPermission() { try { var granted = await PermissionsAndroid.request( PermissionsAndroid.PERMISSIONS.READ_SMS, { title: "Auto Verification OTP", message: "need access to read sms, to verify OTP" } ); if (granted === PermissionsAndroid.RESULTS.GRANTED) { console.log("sms read permissions granted", granted); granted = await PermissionsAndroid.request( PermissionsAndroid.PERMISSIONS.RECEIVE_SMS, { title: "Receive SMS", message: "Need access to receive sms, to verify OTP" } ); if (granted === PermissionsAndroid.RESULTS.GRANTED) { console.log("RECEIVE_SMS permissions granted", granted); } else { console.log("RECEIVE_SMS permissions denied"); } } else { console.log("sms read permissions denied"); } } catch (err) { console.log(err); } }

vivekkriti commented 5 years ago

Any update... Same problem. Are the developers seeing this for a solution OR we need to implement this naively

roninprogrammer commented 5 years ago

It's working yet wont useful for google play store due to SMS policy .. So stop using this plugin and move towards SMS retrieving API