sendSMS method

  1. @override
Future<bool?> sendSMS({
  1. required String phoneNumber,
  2. required String message,
  3. required int subId,
  4. int timeoutSeconds = 0,
})
override

Supported for both android and iOS This requires the SEND_SMS permissions for android. SMS is sent in the background for android and for iOS the plugin uses MFMessageComposeViewController

Implementation

@override
Future<bool?> sendSMS({
  required String phoneNumber,
  required String message,
  required int subId,
  int timeoutSeconds = 0,
}) async {
  final result = await methodChannel.invokeMethod('send_sms', <String, dynamic>{
    "phone": phoneNumber,
    "msg": message,
    "subId": subId,        // Android only; iOS ignores it
    "timeout": timeoutSeconds,
  });

  if (result is bool) return result;             // Android
  if (result is String) return result == 'sent'; // iOS ("sent")
  return null;
}