Skip to content

Commit f62cbf8

Browse files
author
Olivier Radisson
committed
can now send multiple SMS at once, need to get a list from send_api
1 parent 2900485 commit f62cbf8

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,10 @@ POST https://yourcustomurl.com/send_api
4646
action: SEND
4747
```
4848

49-
2- It should read a JSON containing *message*, *number* and *id*, or an empty response if there is nothing to send
49+
2- It should read a JSON containing a list of : *message*, *number* and *id*, or an empty response if there is nothing to send
5050
```
51-
{ "message": "hola mundo!", "number": "3472664455", "messageId": "1" }
51+
[{ "message": "hola mundo!", "number": "3472664455", "messageId": "1" },
52+
{ "message": "bonjour le monde!", "number": "3472664455", "messageId": "2" }]
5253
```
5354

5455
3- The app will send the SMS *message* to *number*

app/src/main/java/com/ar/smshub/SendTask.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,11 @@ class SendTask constructor(_settings: SettingsManager, _context: Context) : Time
104104
})
105105
return
106106
}
107-
var sms: SMS? = SMS("", "", "")
107+
var smsList: List<SMS>? = null;
108108
var canSend: Boolean = false
109109
try {
110-
sms = Klaxon().parse<SMS>(apiResponse.text)
110+
smsList = Klaxon().parseArray(apiResponse.text)
111+
Log.d("send", "smsList = $smsList")
111112
canSend = true
112113
} catch (e: com.beust.klaxon.KlaxonException) {
113114
// NOTE: The http response body MUST be an empty string
@@ -125,8 +126,10 @@ class SendTask constructor(_settings: SettingsManager, _context: Context) : Time
125126
} finally {
126127
// optional finally block
127128
}
128-
if (canSend) {
129-
sms!!.send(mainActivity, settings);
129+
if (canSend && smsList != null) {
130+
for(sms in smsList) {
131+
sms.send(mainActivity, settings);
132+
}
130133
}
131134

132135

0 commit comments

Comments
 (0)