sendSms method

  1. @override
Future<bool> sendSms({
  1. required String phoneNumber,
  2. required String message,
})
override

Send SMS message

Implementation

@override
Future<bool> sendSms({
  required String phoneNumber,
  required String message,
}) async {
  try {
    final result = await methodChannel.invokeMethod<bool>('sendSms', {
      'phoneNumber': phoneNumber,
      'message': message,
    });
    return result ?? false;
  } on PlatformException catch (e) {
    if (e.code == 'SMS_NOT_AVAILABLE') {
      throw UnsupportedError('SMS is not available on this device');
    } else if (e.code == 'NO_VIEW_CONTROLLER') {
      throw StateError('No view controller available to present SMS composer');
    } else if (e.code == 'SMS_SEND_ERROR') {
      throw StateError('Failed to send SMS: ${e.message}');
    }
    rethrow;
  }
}