diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/ThreadActivity.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/ThreadActivity.kt index c94cfd4e..33433014 100644 --- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/ThreadActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/activities/ThreadActivity.kt @@ -1228,8 +1228,9 @@ class ThreadActivity : SimpleActivity() { sendMessageCompat(text, addresses, subscriptionId, attachments) ensureBackgroundThread { val messageIds = messages.map { it.id } - val message = getMessages(threadId, getImageResolutions = true, limit = 1).firstOrNull { it.id !in messageIds } - if (message != null) { + val messages = getMessages(threadId, getImageResolutions = true, limit = maxOf(1, attachments.size)) + .filter { it.id !in messageIds } + for (message in messages) { insertOrUpdateMessage(message) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/messaging/Messaging.kt b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/messaging/Messaging.kt index 5a92c719..3f786503 100644 --- a/app/src/main/kotlin/com/simplemobiletools/smsmessenger/messaging/Messaging.kt +++ b/app/src/main/kotlin/com/simplemobiletools/smsmessenger/messaging/Messaging.kt @@ -40,7 +40,16 @@ fun Context.sendMessageCompat(text: String, addresses: List, subId: Int? val isMms = attachments.isNotEmpty() || isLongMmsMessage(text, settings) || addresses.size > 1 && settings.group if (isMms) { - messagingUtils.sendMmsMessage(text, addresses, attachments, settings) + // we send all MMS attachments separately to reduces the chances of hitting provider MMS limit. + if (attachments.size > 1) { + for (i in 0 until attachments.lastIndex - 1) { + val attachment = attachments[i] + messagingUtils.sendMmsMessage("", addresses, listOf(attachment), settings) + } + } + + val lastAttachment = attachments[attachments.lastIndex] + messagingUtils.sendMmsMessage(text, addresses, listOf(lastAttachment), settings) } else { try { messagingUtils.sendSmsMessage(text, addresses.toSet(), settings.subscriptionId, settings.deliveryReports)