0

I am using MFMessageComposeViewController to send SMS from my app.

The didFinishWithResult delegate method of MFMessageComposeViewController shows that the message has been sent successfully but actually this SMS failed to send due to insufficient balance. So MFMessageComposeViewController does not show me the correct result.

How do I know that the Messages app failed to send an SMS? Is there any way to get the failed status?

shim
  • 9,289
  • 12
  • 69
  • 108
Shariif Islam
  • 259
  • 1
  • 2
  • 15
  • Detecting Changes to the Availability of Messaging To be notified of changes to the messaging capabilities of the current device, add an observer to the MFMessageComposeViewControllerTextMessageAvailabilityDidChange notification. The system delivers that notification to your observer when the status of messaging changes. For more information: https://developer.apple.com/reference/messageui/mfmessagecomposeviewcontroller#//apple_ref/occ/instm/MFMessageComposeViewController/addAttachmentURL:withAlternateFilename: – Mannopson Feb 02 '17 at 06:25
  • Thanks for your concern. Actually, this notification posted when the value returned by the canSendText() class method has changed and canSendText() is check only if the device capable of sending SMS. So, if Messages app failed to send SMS, we don't get that failed status. Exactly, i need the status when Messages app failed to send that SMS which i am sending through MFMessageComposeViewController. – Shariif Islam Feb 02 '17 at 08:45
  • Why? All of status stuff is there, I mean Apple's documentation. The MessageComposeResult must be responsible for providing these status for you. They're .sent, .cancelled, .failed! The system knows and immediately tells you about it's status. Hope it helps you – Mannopson Feb 02 '17 at 09:42
  • An alternate way to compose SMS messages is to create and open a URL that uses the sms scheme. – Mannopson Feb 02 '17 at 09:59
  • Sending SMS by create and open URL is not suitable for me, because its not allow to send message body. – Shariif Islam Feb 02 '17 at 10:37
  • Unfortunately your words are right! Good luck. But your problem is so strange for me – Mannopson Feb 02 '17 at 10:40
  • May be, but thing is that MessageComposeResult is showing sent which is actually failed SMS. Thank You – Shariif Islam Feb 02 '17 at 11:03
  • Are you solved your problems? – Mannopson Feb 07 '17 at 07:24
  • Not yet. As @OMK said its not possible to know if SMS send failed by Messages app. Apple restrict all over accessing Messages app, get phone number. So, i should change my way. – Shariif Islam Feb 08 '17 at 12:20

1 Answers1

2

It's not possible to know if the message is Sent or Failed from Messages app.

We get a result in messageComposeViewController:didFinishWithResult: once a message has been successfully queued for sending.

OnkarK
  • 3,745
  • 2
  • 26
  • 33