EddieKamau / sms_advanced

This is an SMS library for Flutter. Its allow to send, receive, query sms messages, sms delivery and query contacts info. Currently supporting only android
MIT License
31 stars 69 forks source link

Sending SMS onchange listener. #29

Open lloydie008 opened 1 year ago

lloydie008 commented 1 year ago

In sending Sms the listening status is not updating after sending another SMS. but when i restarted my app, it listen once then failed to listen again.

SmsMessage message = new SmsMessage(address, 'Hello flutter world!');
message.onStateChanged.listen((state) {
  if (state == SmsMessageState.Sent) {
    print("SMS is sent!");
  } else if (state == SmsMessageState.Delivered) {
    print("SMS is delivered!");
  } else if (state == SmsMessageState.Fail) {
    print("SMS is failed!");
  }
});
sender.sendSms(message);

}

Keveltiah commented 1 year ago

@lloydie008 I got the same problem, i noticed that the problem was inside sms_adavced.dart file at line 365. if (_sentMessages.containsKey(id)). The value of id is always 0 and i dont know why. The workaround for me was to update this part of the code, pleas take a look here: https://github.com/Keveltiah/sms_advanced/commit/1cb942cff28e0621855cd0fbc41bbcf353e77c6b