shounakmulay / Telephony

Flutter plugin for telephony features like query device sms directory, listen for incoming messages, retrieve various network parameters, etc.
https://telephony.shounakmulay.dev
MIT License
137 stars 124 forks source link

Sms failure handling #178

Open redanium opened 1 year ago

redanium commented 1 year ago

This fix will handle all sms sending failures (_RESULT_ERROR_GENERIC_FAILURE,RESULT_ERROR_NO_SERVICE,RESULT_ERROR_NULL_PDU,RESULT_ERROR_RADIO_OFF_) to SMS_FAIL.

For example :

final SmsSendStatusListener listener = (SendStatus status) {
    // Handle the status
    switch (status) {
        case SendStatus.SENT:
          print("SMS is sent!");
          break;
        case SendStatus.DELIVERED:
          print("SMS delivered.");
          break;
        case SendStatus.FAIL:
          print("Error sending sms");
          break;
        default:
      }
};

telephony.sendSms(
    to: "1234567890",
    message: "May the force be with you!",
    statusListener: listener
);