I am trying to send an sms using MFMessagingComposeViewController
this is the code in swift :
after importing MessageUI
let msg:MFMessageComposeViewController=MFMessageComposeViewController()
msg.recipients=["7236446823423"]
msg.body="txt"
self.presentViewController(msg,animated:true,completion:nil)
i get an error :
libc++abi.dylib terminating with uncaught exception of type NSException
Check if MFMessageComposeViewController can send text 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....")
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.