Download the PHP package atendwa/nativephp-sms-reader without Composer
On this page you can find all versions of the php package atendwa/nativephp-sms-reader. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download atendwa/nativephp-sms-reader
More information about atendwa/nativephp-sms-reader
Files in atendwa/nativephp-sms-reader
Package nativephp-sms-reader
Short Description A NativePHP Mobile plugin that lets your Android app read SMS messages from the device inbox and listen for incoming SMS in real time.
License MIT
Homepage https://github.com/atendwa/nativephp-sms-reader
Informations about the package nativephp-sms-reader
atendwa/nativephp-sms-reader
A NativePHP Mobile plugin for Laravel that lets your Android app read SMS messages from the device inbox and listen for incoming SMS in real time.
Introduction
atendwa/sms-reader bridges the Android SMS ContentProvider and BroadcastReceiver into your Laravel application. It provides:
SmsReader::getMessages()— query the device inbox with optional sender, limit, and date filters.SmsReader::getMessagesForSenders()— batch inbox queries across multiple senders.SmsReceivedevent — fired in real time whenever a new SMS arrives on the device.
The plugin only operates inside the NativePHP Android runtime. On the web, in Artisan, or on iOS it returns empty results rather than throwing, so your code runs safely in all environments.
Requirements
| Requirement | Version |
|---|---|
| PHP | 8.3+ |
| Laravel | 11+ |
| NativePHP Mobile | 3.0+ |
| Android | API 26+ (Android 8.0) |
Installation
1. Add the package via Composer
2. Register the plugin with NativePHP
NativePHP requires every plugin to be explicitly registered as a security measure — it prevents transitive Composer dependencies from silently bundling native code into your app.
This adds the service provider to app/Providers/NativeServiceProvider.php:
3. Rebuild the app
Plugin changes require a full rebuild:
Verifying the Installation
Check the plugin is registered
You should see atendwa/sms-reader in the output.
Validate the plugin manifest
Test the bridge on-device
Add a temporary debug button in a Livewire component to confirm the bridge is reachable:
If the bridge is working you will see a JSON string like:
If nativephp_call() does not exist (e.g. you are running on the web), the method returns a descriptive string rather than throwing.
Usage
Reading inbox messages
Available options:
| Option | Type | Description |
|---|---|---|
sender |
string |
Filter by originating address (exact match) |
limit |
int |
Maximum number of messages to return (default 500) |
since |
int |
Only return messages newer than this Unix timestamp in milliseconds |
Reading from multiple senders
Results are merged and sorted by timestamp descending.
Listening for incoming SMS (real time)
Use the #[OnNative] attribute in any Livewire component:
Livewire v3 & v4: The
#[OnNative]attribute is provided by NativePHP Mobile and works with both Livewire v3 and v4.
JavaScript Usage
For Vue, React, Inertia, or vanilla JS apps, import directly from the package's JS file:
TypeScript definitions are included at resources/js/smsReader.d.ts.
Reading inbox messages
Reading from multiple senders
Listening for incoming SMS (real time)
If you prefer to use NativePHP's own JS event bus directly, the exported constant SMS_RECEIVED_EVENT holds the fully-qualified event class name:
Vue 3 (Composition API)
React
Permissions
The plugin declares the required permissions automatically via nativephp.json. You do not need to add them manually.
| Permission | Purpose |
|---|---|
READ_SMS |
Query the inbox ContentProvider |
RECEIVE_SMS |
Listen for incoming messages via BroadcastReceiver |
On Android 6.0+ these are runtime permissions. The plugin requests them automatically the first time getMessages() is called. If the user has not granted them yet, a RuntimeException is thrown with the message:
SmsReader bridge error [PERMISSION_REQUIRED]: READ_SMS permission has not been granted...
Show the user a prompt and retry after they grant the permission.
Error Handling
getMessages() throws a RuntimeException in these situations:
| Condition | Exception message |
|---|---|
nativephp_call not in registry |
SmsReader.GetMessages not found in bridge registry |
| Bridge returned invalid JSON | SmsReader bridge returned invalid JSON: ... |
| Permission not granted | SmsReader bridge error [PERMISSION_REQUIRED]: ... |
| Permission denied by system | SmsReader bridge error [PERMISSION_DENIED]: ... |
| Any other native error | SmsReader bridge error [ERROR_CODE]: ... |
The JavaScript getMessages() function throws an Error with the same message format:
Testing
The package ships with a Pest test suite that covers all three methods and the SmsReceived event. Because the bridge only exists inside the NativePHP Android runtime, tests use a thin subclass that overrides two protected hook methods (isOnDevice() and callBridge()) to simulate on-device behaviour without requiring a real device.
Support
Found a bug or have a question? Open an issue on GitHub or reach out directly:
Email: [email protected]
License
MIT — Copyright © 2026 Anthony Tendwa