A React Native library for reading SMS messages from the device inbox.
- Fetch SMS messages from the inbox.
- Filter messages by date, sender, thread ID, etc.
- Compatible with both Android and iOS.
npm install react-native-get-sms-list
# OR
yarn add react-native-get-sms-list
Add the following permission to your AndroidManifest.xml
file:
<uses-permission android:name="android.permission.READ_SMS"/>
<uses-permission android:name="android.permission.RECEIVE_SMS"/>
import { readSMS } from 'react-native-get-sms-list';
const fetchMessages = async () => {
try {
const messages = await readSMS({
type: 'inbox',
limit: 10,
orderBy: 'date desc',
});
console.log(messages);
} catch (error) {
console.error(error);
}
};
This package includes TypeScript type definitions:
type SMS = {
address: string;
body: string;
date: string;
id: string;
thread_id: string;
};
export type FilterSMS = {
type?: 'inbox' | 'sent' | 'draft' | 'outbox' | 'failed' | 'queued';
id?: string;
address?: string;
orderBy?: 'date asc' | 'date desc';
minDate?: string;
maxDate?: string;
limit?: number;
thread_id?: string;
};
Feel free to open issues or submit pull requests to improve this package.
MIT