'How to get and paste sms with Android on Expo project?

Expo project

"expo": "^42.0.3"

I add permission READ_SMS for Android to get sms

app.json:

"android": {
  "package": "com.thecoinscompany.loanapp",
  "useNextNotificationsApi": true,
  "googleServicesFile": "./google-services.json",
  "versionCode": 18,
  "permissions": [
    "READ_SMS",
  ],
}

I use <TextInput /> to get sms is working on iOS, althought I don't use contentType="oneTimeCode"

<TextInput
  allowFontScaling={false}
  style={styles.inputStyle}
  ref={ref}
  keyboardType="numeric"
  autoComplete="sms-otp" // set this props for Android
  value={value}
  onChangeText={text => {
    // When user click the sms view above keybaord, it can be triggered on iOS
    console.log('get sms text', text)
  }
/>

In Android, when sms comes, it just pop up a notification, click it can't get the value.

I check Expo document, it only supports for sending sms. https://docs.expo.dev/versions/latest/sdk/sms/

There is a library supports for Android to get sms on pure react native project. https://github.com/briankabiro/react-native-get-sms-android

Is any way to get sms with Android, if I use Expo project ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source