diff --git a/app/src/main/java/chat/rocket/android/contacts/worker/ContactsSyncWorker.kt b/app/src/main/java/chat/rocket/android/contacts/worker/ContactsSyncWorker.kt index ec8b2e72c9..ca267bf58b 100644 --- a/app/src/main/java/chat/rocket/android/contacts/worker/ContactsSyncWorker.kt +++ b/app/src/main/java/chat/rocket/android/contacts/worker/ContactsSyncWorker.kt @@ -171,7 +171,19 @@ class ContactsSyncWorker(context : Context, params : WorkerParameters) } private fun formatPhoneNumber(phone: String, country:String): String? { - return PhoneNumberUtils.formatNumberToE164(phone.replace("-|\\s|\\(|\\)".toRegex(), ""), country) + var number = PhoneNumberUtils.formatNumberToE164(phone.replace("-|\\s|\\(|\\)".toRegex(), ""), country) + + // Default fallback: Mexico + if (number==null) { + number = PhoneNumberUtils.formatNumberToE164(phone.replace("-|\\s|\\(|\\)".toRegex(), ""), "MX") + } + + // Default fallback, second priority: US + if (number==null) { + number = PhoneNumberUtils.formatNumberToE164(phone.replace("-|\\s|\\(|\\)".toRegex(), ""), "US") + } + + return number } }