TelephonySmsErrorCode enum

The reason a TelephonySmsException was thrown.

Values fall into three groups: failures raised by the plugin before the message reached the radio, failures the radio itself reported, and the state of the send afterwards.

Android defines around eighty distinct send result codes. They are grouped here by what a caller can do about them rather than kept one-to-one, so several platform codes can produce the same value.

Inheritance
Available extensions

Values

invalidArguments → const TelephonySmsErrorCode

phone or message was null, empty, blank, or rejected by the platform.

Also raised when the message is too long to fit in one multipart message.

const TelephonySmsErrorCode('invalid_arguments')
permissionDenied → const TelephonySmsErrorCode

SEND_SMS has not been granted. Call requestPermission() first.

const TelephonySmsErrorCode('permission_denied')
permissionNotDeclared → const TelephonySmsErrorCode

The host app's manifest does not declare SEND_SMS.

The permission can never be granted until it does, so the dialog never appears and every request comes straight back denied. Add <uses-permission android:name="android.permission.SEND_SMS" /> to android/app/src/main/AndroidManifest.xml.

const TelephonySmsErrorCode('permission_not_declared')
noActivity → const TelephonySmsErrorCode

No activity was attached, so the permission dialog could not be shown.

const TelephonySmsErrorCode('no_activity')
activityDetached → const TelephonySmsErrorCode

The activity went away before the permission request was answered.

const TelephonySmsErrorCode('activity_detached')
alreadyRequesting → const TelephonySmsErrorCode

A permission request was already in flight.

const TelephonySmsErrorCode('already_requesting')
smsManagerUnavailable → const TelephonySmsErrorCode

The device does not provide an SmsManager.

const TelephonySmsErrorCode('sms_manager_unavailable')
noTelephony → const TelephonySmsErrorCode

The device cannot send SMS at all — a tablet or other Wi-Fi-only device.

const TelephonySmsErrorCode('no_telephony')
noSmsSubscription → const TelephonySmsErrorCode

No default SMS subscription is set on a device with more than one SIM.

Sending would otherwise make the system interrupt with a SIM-picker dialog in the foreground, or fail outright in the background, so the plugin refuses up front. The user must set a default under Settings → Network & internet → SIMs → SMS. Not retryable until they do.

const TelephonySmsErrorCode('no_sms_subscription')
receiverUnavailable → const TelephonySmsErrorCode

The plugin could not register the receiver it needs to confirm sends.

Without it no send can ever be confirmed, so sending is refused rather than done blind. Two things cause it: a merged manifest missing the ${applicationId}.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION that androidx.core normally contributes, or an androidx.core resolved below 1.9.0. Not retryable — both are build-configuration problems.

const TelephonySmsErrorCode('receiver_unavailable')
sendFailed → const TelephonySmsErrorCode

SmsManager rejected the message before it reached the radio.

const TelephonySmsErrorCode('send_failed')
noContext → const TelephonySmsErrorCode

The plugin is not attached to a Flutter engine.

const TelephonySmsErrorCode('no_context')
unsupportedPlatform → const TelephonySmsErrorCode

This platform has no implementation of the plugin.

telephony_sms is Android only: iOS does not permit sending SMS without user interaction, and there is no equivalent of SmsManager.

const TelephonySmsErrorCode('unsupported_platform')
noService → const TelephonySmsErrorCode

The device has no cellular service. Safe to retry once service returns.

const TelephonySmsErrorCode('no_service')
radioOff → const TelephonySmsErrorCode

The radio is off — airplane mode, most likely. Safe to retry once it is on.

const TelephonySmsErrorCode('radio_off')
radioNotAvailable → const TelephonySmsErrorCode

The radio is not available. Usually transient.

const TelephonySmsErrorCode('radio_not_available')
nullPdu → const TelephonySmsErrorCode

The telephony stack produced a null PDU. Not retryable as-is.

const TelephonySmsErrorCode('null_pdu')
genericFailure → const TelephonySmsErrorCode

The radio reported an unspecified failure. Often transient.

const TelephonySmsErrorCode('generic_failure')
limitExceeded → const TelephonySmsErrorCode

The device's SMS rate limit was reached.

Android throttles how many messages an app may send in a window, so this is the usual failure when sending in a loop. Back off and retry rather than retrying immediately.

const TelephonySmsErrorCode('limit_exceeded')
fdnCheckFailure → const TelephonySmsErrorCode

The number is not in the SIM's fixed dialling list.

const TelephonySmsErrorCode('fdn_check_failure')
shortCodeNotAllowed → const TelephonySmsErrorCode

Sending to this short code was not permitted, typically a premium number the user declined to pay for.

const TelephonySmsErrorCode('short_code_not_allowed')
shortCodeNeverAllowed → const TelephonySmsErrorCode

Sending to this short code is never permitted.

const TelephonySmsErrorCode('short_code_never_allowed')
networkReject → const TelephonySmsErrorCode

The network rejected the message.

const TelephonySmsErrorCode('network_reject')
networkError → const TelephonySmsErrorCode

The network could not carry the message. Usually transient.

const TelephonySmsErrorCode('network_error')
modemError → const TelephonySmsErrorCode

The modem reported an error. Often transient.

const TelephonySmsErrorCode('modem_error')
noMemory → const TelephonySmsErrorCode

The device is out of memory.

const TelephonySmsErrorCode('no_memory')
noResources → const TelephonySmsErrorCode

The telephony stack is out of resources.

const TelephonySmsErrorCode('no_resources')
systemError → const TelephonySmsErrorCode

The telephony system reported an internal error.

const TelephonySmsErrorCode('system_error')
invalidSmsFormat → const TelephonySmsErrorCode

The message format is invalid.

const TelephonySmsErrorCode('invalid_sms_format')
encodingError → const TelephonySmsErrorCode

The message could not be encoded for the network.

const TelephonySmsErrorCode('encoding_error')
invalidSmscAddress → const TelephonySmsErrorCode

The SMS centre address is invalid.

const TelephonySmsErrorCode('invalid_smsc_address')
operationNotAllowed → const TelephonySmsErrorCode

The operation is not allowed on this device.

const TelephonySmsErrorCode('operation_not_allowed')
blockedDuringEmergency → const TelephonySmsErrorCode

Sending is blocked while an emergency call is in progress.

const TelephonySmsErrorCode('blocked_during_emergency')
noDefaultSmsApp → const TelephonySmsErrorCode

No SMS subscription could be resolved for the send.

Despite the platform name, on a modern multi-SIM device this usually means no default SMS SIM is set rather than a missing default SMS app. Set one under Settings → Network & internet → SIMs → SMS. See noSmsSubscription, which the plugin raises up front for the same underlying cause.

const TelephonySmsErrorCode('no_default_sms_app')
userNotAllowed → const TelephonySmsErrorCode

This user profile is not allowed to send SMS.

const TelephonySmsErrorCode('user_not_allowed')
simAbsent → const TelephonySmsErrorCode

There is no SIM.

const TelephonySmsErrorCode('sim_absent')
simError → const TelephonySmsErrorCode

The SIM could not be used — locked, busy, full, or in an invalid state.

const TelephonySmsErrorCode('sim_error')
cancelled → const TelephonySmsErrorCode

The send was cancelled by the platform.

const TelephonySmsErrorCode('cancelled')
sendTimeout → const TelephonySmsErrorCode

No send confirmation arrived before the timeout.

This means the plugin could not determine whether the message went out. It may have. For that reason it is deliberately not isTransient: an automatic retry would send the message a second time whenever it did go out. Decide per message whether a possible duplicate is acceptable before retrying by hand — and if it is not, treat this as a failure to surface, not to retry.

const TelephonySmsErrorCode('send_timeout')
deliveryTimeout → const TelephonySmsErrorCode

The message was sent, but no delivery report arrived before the timeout.

This is the common outcome of SmsCompletion.delivered: many carriers never emit delivery reports. Do not retry — the message went out.

const TelephonySmsErrorCode('delivery_timeout')
notDelivered → const TelephonySmsErrorCode

The message was sent, but the carrier reported it as not delivered.

const TelephonySmsErrorCode('not_delivered')
detached → const TelephonySmsErrorCode

The plugin detached from the engine while the call was in flight.

const TelephonySmsErrorCode('detached')
unknown → const TelephonySmsErrorCode

The platform reported a code this version of the plugin does not know.

const TelephonySmsErrorCode('unknown')

Properties

code String
The raw string used on the method channel.
final
hashCode int
The hash code for this object.
no setterinherited
index int
A numeric identifier for the enumerated value.
no setterinherited
isTransient bool
Whether retrying the same send could plausibly succeed later.
no setter
name String

Available on Enum, provided by the EnumName extension

The name of the enum value.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

fromCode(String? code) TelephonySmsErrorCode
Maps a platform error code onto its enum value, falling back to unknown.

Constants

values → const List<TelephonySmsErrorCode>
A constant List of the values in this enum, in order of their declaration.