It's possible to check SMS sending status? e.g.
MFMessageComposeViewController * smsPicker = [[MFMessageComposeViewController alloc] init];
smsPicker.messageComposeDelegate = self;
smsPicker.body = @"Body";
[self presentModalView开发者_JAVA技巧Controller:smsPicker animated:YES];
[smsPicker release];
I don't know why, but the delegate - (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult) result; executing before sending and works if user cancelled SMS.
And I need to know, if SMS sent or failed (e.g. cell network error or something wrong). Thanks for future help!
You can use the result
parameter messageComposeViewController:didFinishWithResult:
to check the status of the message. Its type is MessageComposeResult:
enum MessageComposeResult {
MessageComposeResultCancelled,
MessageComposeResultSent,
MessageComposeResultFailed
};
Bear in mind that MessageComposeResultSent
may only be interpreted as a successful queueing of the message for later sending. The actual send will occur when the device is able to send.
How can I check if device is able to send?
To test whether a device is capable of sending text messages, use MFMessageComposeViewController
's canSendText class method. According to the documentation, you should always call this method before attempting to present the message compose view controller.
However, this will not tell you if the device is able to send the message now (in case you asked with this statement in mind: The actual send will occur when the device is able to send).
Unfortunately it does not account for cell network interruptions at the very least. For example when in airplane mode the delegate receives a MessageComposeResultSent
!
I have filed a radar for this. Duplicating it may get the issue resolved sooner.
精彩评论