@ghala-pkg/rn-read-sms
v1.0.1
Published
React Native SMS reader for Android
Maintainers
Readme
@ghala-pkg/rn-read-sms
@ghala-pkg/rn-read-sms is a React Native library for Android that allows your app to listen to incoming SMS messages in real-time. It is useful for OTP verification or any feature that requires reading SMS messages automatically. iOS is not supported due to platform restrictions.
The library handles:
- Listening for incoming SMS messages
- Requesting and checking SMS permissions
- Starting and stopping the SMS listener
- Type-safe TypeScript support
Installation
bun add @ghala-pkg/rn-read-sms
# or
npm install @ghala-pkg/rn-read-sms
# or
yarn add @ghala-pkg/rn-read-smsUsage Example
import { listen, stop, askPermissions } from "@ghala-pkg/rn-read-sms";
const initSMSListener = async () => {
const granted = await askPermissions();
if (!granted) {
console.log("Permissions denied");
return;
}
await listen((status, data, error) => {
if (status === "success") console.log("SMS received:", data);
else console.error("Error:", error);
});
// Later, you can stop listening
// stop();
};
initSMSListener();Notes
- Android only.
- Make sure to declare permissions in
AndroidManifest.xml:
<uses-permission android:name="android.permission.RECEIVE_SMS"/>
<uses-permission android:name="android.permission.READ_SMS"/>- Runtime permissions are required for Android 6.0+ (API 23 and above).
License
MIT © Neurotech Africa
