Skip to content

Commit

Permalink
can now send multiple SMS at once, need to get a list from send_api
Browse files Browse the repository at this point in the history
  • Loading branch information
Olivier Radisson committed Mar 12, 2022
1 parent 2900485 commit f62cbf8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ POST https://yourcustomurl.com/send_api
action: SEND
```

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

3- The app will send the SMS *message* to *number*
Expand Down
11 changes: 7 additions & 4 deletions app/src/main/java/com/ar/smshub/SendTask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,11 @@ class SendTask constructor(_settings: SettingsManager, _context: Context) : Time
})
return
}
var sms: SMS? = SMS("", "", "")
var smsList: List<SMS>? = null;
var canSend: Boolean = false
try {
sms = Klaxon().parse<SMS>(apiResponse.text)
smsList = Klaxon().parseArray(apiResponse.text)
Log.d("send", "smsList = $smsList")
canSend = true
} catch (e: com.beust.klaxon.KlaxonException) {
// NOTE: The http response body MUST be an empty string
Expand All @@ -125,8 +126,10 @@ class SendTask constructor(_settings: SettingsManager, _context: Context) : Time
} finally {
// optional finally block
}
if (canSend) {
sms!!.send(mainActivity, settings);
if (canSend && smsList != null) {
for(sms in smsList) {
sms.send(mainActivity, settings);
}
}


Expand Down

0 comments on commit f62cbf8

Please sign in to comment.