sendSms method
Send an SMS
Take a message in argument + 2 functions that will be called on success or on error
This function will not set automatically thread id, you have to do it
Implementation
Future<SmsMessage?> sendSms(SmsMessage? msg, {SimCard? simCard}) async {
if (msg == null || msg.address == null || msg.body == null) {
if (msg == null) {
throw ("no given message");
} else if (msg.address == null) {
throw ("no given address");
} else if (msg.body == null) {
throw ("no given body");
}
return null;
}
msg.state = SmsMessageState.Sending;
Map map = msg.toMap;
if(this._sentId != null)this._sentMessages?.putIfAbsent(this._sentId!, () => msg);
map['sentId'] = this._sentId;
if (simCard != null) {
map['subId'] = simCard.slot;
}
if (this._sentId != null) this._sentId = this._sentId! + 1;
if (simCard != null) {
map['simCard'] = simCard.imei;
}
await _channel?.invokeMethod("sendSMS", map);
msg.date = new DateTime.now();
return msg;
}