babariviere / flutter_sms

SMS library for flutter
MIT License
87 stars 158 forks source link

How to determine if message failed in sending? #35

Closed litzbalane2017 closed 6 years ago

litzbalane2017 commented 6 years ago

I am trying how to determine if a message fails in sending, which can do so for various of reasons (no credit, bad signal and etc). However, I cannot seem to catch if the message fails when using:

SmsMessage message = new SmsMessage("address", "content");
message.onStateChanged.listen((state) {
  if (state == SmsMessageState.Sent) {
    print("SMS is sent!");
  } else if (state == SmsMessageState.Delivered) {
    print("SMS is delivered!");
  } else {
    print(state); <-- This will show "SmsMessageState.Sending"
  }
});
sender.sendSms(message);

There seems to be no enum type for SmsMessageState for "failed":

enum SmsMessageState {
  Sending,
  Sent,
  Delivered,
  None,
}

Also, even if the message fails in sending, the SmsMessageState.Sent still runs. I have not seen SmsMessageState.Delivered being triggered, even if the message is successfully sent or not.

babariviere commented 6 years ago

I will add it today

babariviere commented 6 years ago

There is now a fail state

litzbalane2017 commented 6 years ago

There is no a fail state

I think you meant "now" has a fail state.

I can confirm that the new fail state is working. I am now seeing correct fail state when messages fail in sending. Thank you for the fast response.

babariviere commented 6 years ago

Yes I have typed too fast haha.

No problem