Package Exports
- @ghala-pkg/rn-read-sms
- @ghala-pkg/rn-read-sms/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@ghala-pkg/rn-read-sms) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
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