sendSMS method

  1. @override
Future<void> sendSMS({
  1. required String phone,
  2. required String message,
  3. SmsCompletion completeOn = SmsCompletion.sent,
  4. Duration timeout = const Duration(seconds: 30),
})
override

Sends message to phone, completing when completeOn is satisfied or failing after timeout.

Implementation

@override
Future<void> sendSMS({
  required String phone,
  required String message,
  SmsCompletion completeOn = SmsCompletion.sent,
  Duration timeout = const Duration(seconds: 30),
}) async {
  try {
    await methodChannel.invokeMethod<void>('sendSMS', {
      'phone': phone,
      'message': message,
      'completeOn': completeOn.value,
      'timeoutMillis': timeout.inMilliseconds,
    });
  } on PlatformException catch (e) {
    throw _asTelephonySmsException(e);
  } on MissingPluginException {
    throw _unsupportedPlatform();
  }
}