我正在尝试使用MFMessagingComposeViewController发送短信
这是swift中的代码:
导入MessageUI后
let msg:MFMessageComposeViewController=MFMessageComposeViewController()
msg.recipients=["7236446823423"]
msg.body="txt"
self.presentViewController(msg,animated:true,completion:nil)
我收到错误:
libc ++ abi.dylib以NSException类型的未捕获异常终止
答案 0 :(得分:2)
检查MFMessageComposeViewController是否可以发送文本canSendText
:
if MFMessageComposeViewController.canSendText(){
let msg:MFMessageComposeViewController=MFMessageComposeViewController()
msg.recipients=["7236446823423"]
msg.body="txt"
self.presentViewController(msg,animated:true,completion:nil)
}
else {
NSLog("your device do not support SMS....")
}