Poll (Unificado)
Gu铆a de integraci贸n de la aplicaci贸n m贸vil
Poll (Unificado)
El endpoint preferido para el bucle de servicio de Android. Un 煤nico POST reemplaza llamadas separadas a heartbeat, pending_messages, get_config y la obtenci贸n de comandos.
Recommended: Use
poll as your primary background-service loop. It replaces pending_messages, heartbeat, get_config, and command fetching in a single request.
Cuerpo de la solicitud (all fields optional)
| Campo | Tipo | Descripci贸n |
|---|---|---|
| service_active | boolean | true si el servicio en segundo plano est谩 ejecut谩ndose. |
| sms_count | integer | Total de SMS enviados desde el 煤ltimo reinicio. |
| fail_count | integer | Total de mensajes fallidos desde el 煤ltimo reinicio. |
| whatsapp_enabled | boolean | true si WhatsApp est谩 conectado en el dispositivo. |
| is_default_sms | boolean | true si esta app es el manejador SMS predeterminado. |
| fcm_token | string | Token FCM actualizado (enviar solo cuando cambie). |
| ack_ids | integer[] | Array de IDs de comandos para confirmar y eliminar antes de recibir nuevos. |
| sms_limit | integer | M谩ximo de elementos SMS en esta respuesta (1-10, predeterminado 1). |
| wa_limit | integer | M谩ximo de elementos WhatsApp en esta respuesta (1-10, predeterminado 10). |
Ejemplo de solicitud
cURL
curl -X POST "https://api.rcszilla.com/?endpoint=poll" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR-DEVICE-TOKEN" \
-d '{
"service_active": true,
"sms_count": 42,
"fail_count": 1,
"whatsapp_enabled": false,
"is_default_sms": true,
"ack_ids": [88, 89],
"sms_limit": 5,
"wa_limit": 10
}'
Respuesta
JSON200 OK
{
"success": true,
"config": {
"retry_limit": "3",
"poll_interval_seconds": "5"
},
"commands": [
{"id": 90, "command": "restart_service", "payload": null}
],
"sms": [
{
"id": 103,
"channel": "sms",
"phone": "+40712345678",
"message": "Hello!",
"sim_slot": 0,
"device_id": 7,
"campaign_id": null,
"priority": 1,
"scheduled_at": null,
"created_at": "2026-04-29 10:05:00"
}
],
"whatsapp": [],
"ai_config": null
}
Response Fields
| Campo | Tipo | Descripci贸n |
|---|---|---|
| config | object | Key/value device configuration set from the web panel. |
| commands | array | Pending commands for this device. ACK them via ack_ids on the next poll. |
| sms | array | Claimed SMS messages ready to send (same schema as pending_messages). |
| array | Claimed WhatsApp messages ready to send. | |
| ai_config | object|null | WhatsApp Gemini AI configuration (system prompt, keys, model settings). null if not configured. |
Command Payload
| command | Descripci贸n |
|---|---|
| restart_service | App should restart its background SMS service. |
| set_default_sms | Prompt user to set app as default SMS handler. |
| update_config | Re-fetch config (payload contains changed keys). |
En cada poll, el servidor reinicia autom谩ticamente los mensajes atascados en
processing por m谩s de 5 minutos a pending.Typical Service Loop (Android)
Kotlin (pseudocode)
while (serviceRunning) {
val resp = api.poll(
service_active = true,
sms_count = smsSentTotal,
ack_ids = pendingAckIds
)
pendingAckIds.clear()
for (cmd in resp.commands) handleCommand(cmd)
for (sms in resp.sms) sendSms(sms)
for (wa in resp.whatsapp) sendWhatsApp(wa)
Thread.sleep(pollIntervalMs)
}