
Android SMS Gateway Not Sending? Fix Battery Optimization, Doze, and OEM App Killers (Samsung, Xiaomi, Pixel)
Gateway phone sends fine, then stops after a few hours. Fix Doze, battery optimization, and OEM app killers on Samsung, Xiaomi, Pixel, Oppo, and Vivo.
TL;DR
- In most cases the phone is putting the gateway app to sleep. Set the app to Unrestricted battery, disable the OEM sleep and autostart restrictions, keep the phone on a charger, then re-test.
- The tell is timing. Sends work for a few minutes, then stop once the screen is off and the phone still. That is Doze plus App Standby, not your code.
- Next most common cause is a message stuck in a non-final status because the device is offline. Check the heartbeat first.
- Samsung, Xiaomi, Huawei, Oppo, Realme, OnePlus, and Vivo each add a killer on top of stock Android, each with its own toggle.
- If the phone is healthy and sends still fail, suspect the carrier: identical bursts on a consumer SIM get throttled or blocked.
For a greyed-out SMS permission instead, read the Android 15 and 16 SEND_SMS permission guide.
How do I tell whether it is the phone, the carrier, or the API?
Run five checks in order. Each rules out a layer, and together they take three minutes.
- Read the message status, in the dashboard or with
GET /gateway/messages?direction=sent&limit=10. Each message carries astatusofpending,dispatched,sent,delivered,failed, orunknown, pluserrorCodeanderrorMessagewhen it failed. Everything stuck atpendingordispatchedmeans the phone never picked it up. - Check the device is online. Open Devices in the dashboard. A healthy device shows as Active with a recent heartbeat, battery level, and network. A device silent for long is offline, and sends queue.
- Send a manual SMS from the stock Messages app. If that fails too, blame the SIM or carrier.
- Check the SIM has credit and an SMS allowance. Prepaid SIMs run out silently.
- Check the API response. A
429means a plan limit is used up. A400means no enabled device, an unverified email, or a message that could not be pushed to the phone.
Why does the gateway stop sending after a few hours?
Unplugged, still, and screen off, the phone enters Doze. Network access is suspended, wake locks are ignored, jobs and syncs do not run, and alarms are deferred to maintenance windows that get further apart the longer the phone sits.
App Standby Buckets then grade your app by how recently you used it: active, working set, frequent, rare, restricted. An app you never open drifts to rare, where internet access is limited, or restricted, where jobs run once a day in a batched ten-minute window, even while charging (developer.android.com, checked September 2026).
Each manufacturer then adds a layer no app can grant itself. Hence the reported pattern: nothing goes out until you unlock the phone, then the queue drains at once.
Fix on stock Android and Pixel
Pixel and near-stock phones are the least aggressive, but Doze and standby buckets still apply. Two settings and a charger cover it.
- Settings > Apps > textbee > Battery > Unrestricted, the path on Android 14, 15, and 16. On Android 12 and 13 that screen is Battery optimization, with Don't optimize.
- Settings > Network and internet > Data Saver, then add textbee to Unrestricted data.
- Keep the phone on a charger. A charging device never enters Doze, and opening the app occasionally returns it to the
activebucket.
Fix on Samsung One UI
Samsung is the most common source of this problem: three features can each sleep the app, and one re-applies itself after a few days. Fix all three.
On One UI 5 and 6: Settings > Battery and device care > Battery > Background usage limits. On One UI 7 and 8: Settings > Battery > Background usage limits.
- Turn Put unused apps to sleep off. Samsung otherwise re-sleeps apps after three days by default (dontkillmyapp.com, checked September 2026).
- Open Sleeping apps and Deep sleeping apps, and remove textbee from both.
- Turn Adaptive battery off: Settings > Battery > More battery settings on One UI 5 and 6, directly under Settings > Battery on One UI 7 and 8.
- Set Settings > Apps > textbee > Battery > Unrestricted.
- Long-press the textbee card in recent apps and lock it. Re-check both sleeping lists a week later.
Fix on Xiaomi HyperOS and MIUI
Xiaomi needs Autostart granted explicitly and the battery saver set to no restrictions. Without Autostart the app cannot restart after a reboot or a kill, so the gateway stays down until you open it by hand.
- Autostart. On MIUI 14 and HyperOS: Settings > Apps > Manage apps > textbee > Autostart, or Background autostart under App permissions. Older MIUI: Security > Permissions > Autostart.
- Battery saver. Settings > Apps > Manage apps > textbee > Battery saver > No restrictions, or Settings > Additional settings > Battery and performance > Manage apps battery usage (dontkillmyapp.com, checked September 2026).
- Lock the app in recents. Drag the textbee card down, or long-press it, then lock.
- Enable Keep running after screen off where offered.
Fix on Huawei and Honor
Huawei's PowerGenie is the strictest killer here. The setting that matters is App launch: switch the app to manual management, then enable every toggle.
- Settings > Battery > App launch. Find textbee, turn Manage automatically off, and enable Auto-launch, Secondary launch, and Run in background (dontkillmyapp.com, checked September 2026).
- Turn off any power-saving mode under Settings > Battery.
- On EMUI 6 and later, add the app under Settings > Advanced settings > Battery manager > Protected apps.
Honor phones on MagicOS use the same App launch screen.
Fix on Oppo, Realme and OnePlus (ColorOS and OxygenOS)
These three share a code base, so the same settings apply with different labels. Allow auto-launch and background activity, and on OnePlus also defeat deep optimization.
- Allow auto launch. Settings > Apps > App management > textbee > Allow auto launch. Older builds: the Security app's Startup manager.
- Allow background activity. Settings > Battery > App battery management > textbee.
- Battery optimization. Settings > Battery > Battery optimization, switch to All apps, select textbee, Don't optimize.
- OnePlus only: in Battery optimization, open the overflow menu and turn off Deep optimization (or Adaptive battery) and Sleep standby optimization.
- Lock the app in recents.
These settings revert after firmware updates (dontkillmyapp.com, checked September 2026).
Fix on Vivo and iQOO
Vivo splits the controls between Autostart and a separate high background power consumption allowance. Grant both. iQOO uses the same paths.
- Autostart. Settings > More settings > Applications > Autostart. On Funtouch OS 2.6 and lower: i Manager > App manager > Autostart manager.
- High background power consumption. Settings > Battery > High background power consumption, then allow textbee, or Background power consumption management on some builds.
- Battery. Long-press the app icon, open App info > Battery, set Not optimized. On Android 13 and later also set Unrestricted. Vivo's restrictions vary by model (dontkillmyapp.com, checked September 2026).
Dual-SIM phones: which SIM sends?
By default textbee sends from the device's default SIM. On a dual-SIM phone that is whichever SIM Android has set as default for SMS, which can change after a SIM swap. Set it under Settings > Network and internet > SIMs > SMS.
To pin a SIM per send, pass its simSubscriptionId from the device SIM info:
curl -X POST https://api.textbee.dev/api/v1/gateway/send-sms \
-H 'Content-Type: application/json' \
-H 'x-api-key: YOUR_API_KEY' \
-d '{
"recipients": ["+15550142"],
"message": "Your code is 481920",
"simSubscriptionId": 1
}'Watch for a selected SIM with no SMS allowance: sends then fail with a carrier error while everything else looks healthy.
Messages stuck in a non-final status
A message that is not sent, delivered, or failed is still in flight. The status names the hop it waits on, so match status to hop before retrying. Retrying a dispatched message just sends the text twice.
| Status | What it means | What to do |
|---|---|---|
pending | Accepted and queued server-side. | Wait. Large and scheduled sends go out in waves. |
dispatched | The push service accepted it for the device, which has not confirmed. | Check the device is online. Do not retry yet. |
sent | The device reported it sent. | Nothing. Normal final state without carrier reports. |
delivered | The carrier confirmed delivery. | Nothing. |
failed | Read errorCode and errorMessage. | Retry once after fixing the cause. |
unknown | Undetermined, or older than status tracking. | Treat as unconfirmed. Verify before retrying. |
A batch stuck at pending or dispatched almost always means the phone is asleep or offline. The queue drains when it wakes.
To follow one batch, filter by the smsBatchId the send returned:
curl -s -H 'x-api-key: YOUR_API_KEY' \
'https://api.textbee.dev/api/v1/gateway/messages?smsBatchId=BATCH_ID&status=failed'Carrier throttling and blocking
If the phone is awake and healthy but sends still fail, the carrier is next. Consumer SIMs are provisioned for human texting, so hundreds of near-identical messages in a burst trip spam filters, sometimes silently.
What it looks like:
- Messages return
failedwith a carrier error inerrorMessage, often after a run of successes, or reportsentand never reachdelivered. - Delivery works to your own number, fails to everyone else, and the stock Messages app fails too.
How to back off:
- Slow down. Raise the device send delay. Your ceiling is the carrier's: hundreds to low thousands per day per device.
- Vary the body. Personalize with a name, an order id, or a code.
- Send only what people asked for. Transactional messages to opted-in recipients rarely get filtered. Marketing blasts do.
- Retry with backoff, never immediately.
For carrier-grade bulk volume an Android gateway is the wrong tool and a cloud provider is right. The textbee vs Twilio comparison covers where that line sits.
A dedicated gateway phone checklist
Do these once on a dedicated gateway phone and it stays up.
- Keep it on a charger permanently. A charging phone never enters Doze.
- Set the app to Unrestricted battery.
- Grant autostart on Xiaomi, Oppo, Realme, Vivo, and Huawei.
- Exempt the app from Data Saver so metered connections do not block background data.
- Set a long screen timeout.
- Disable Wi-Fi sleep and adaptive Wi-Fi switching so the connection does not flap.
- Turn auto-updates off for the gateway app, or schedule them outside busy hours.
- Keep notifications enabled. A visible notification keeps the app out of the idle bucket.
- Add the app to Do Not Disturb exceptions.
- Monitor it with a webhook, or poll
GET /gateway/messagesand alert on messages that stay non-final.
Still not working?
- Android 15 and 16 SEND_SMS permission guide for permissions greyed out or reset by an update.
- What is an Android SMS gateway? for how the pieces fit together.
- Docs FAQ for registration, limits, and error codes.
- Email [email protected] with your device id and a failed message id.
Frequently asked questions
Why does my SMS gateway work for a few minutes and then stop?
The phone entered Doze. With the screen off, the device still, and the phone unplugged, Android suspends network access and defers jobs. Set the app to Unrestricted battery, disable your manufacturer's sleep and autostart restrictions, and keep it charging.
Does keeping the phone plugged in actually fix it?
It fixes a large part. A charging device does not enter Doze, and App Standby limits loosen while charging. It does not override manufacturer killers such as Samsung's sleeping apps lists, so set those too.
My message says dispatched but never arrived. Should I resend it?
Not yet. dispatched means the push service accepted the message for the device, which has not confirmed it. Check the device shows online with a recent heartbeat. If it was asleep, the message goes out when it wakes, and resending now sends the text twice.
Which Android phone is best as a dedicated SMS gateway?
A Pixel or any near-stock device, because there are fewest vendor killers to disable. Samsung and Xiaomi work well once configured, they just need more toggles. Any phone on Android 7.0 or higher works.
Why do my messages fail only when I send a lot at once?
Consumer SIMs are filtered for spam. A burst of identical texts to many recipients looks like bulk marketing and gets throttled or blocked, often after a run of successes. Raise the device send delay, personalize each message, and retry with backoff.
Get more textbee in Google Search
Add textbee.dev as a preferred source. Our posts show up more often in your Google results.
You may also like

Android 15+ SEND_SMS Permission: How to Enable SMS Permissions on Android 15 & 16
SMS permission greyed out, not allowed, or missing on Android 15 or 16? Enable SEND_SMS and RECEIVE_SMS for sideloaded and restricted apps in under 2 minutes.

What Is an Android SMS Gateway? How It Works, Pros, Cons & When to Use One (2026)
An Android SMS gateway turns a phone you already own into a programmable SMS sender. Learn how it works, when it beats Twilio, real costs, and setup steps.

Open Source SMS Gateway: Self-Host Your Own with an Android Phone (2026)
textbee is an open source (AGPLv3), self-hostable SMS gateway. What open source means here, self-hosted vs managed, how to run it with Docker Compose, and how it compares with Gammu and other Android gateways.