Hi want want to make a refer a friend through SMS I write the following code. If user is pick on that open the SMS with text but it don't cancel again user will unable go back to app.
if indexPath.item == 1
{
//SMS
if MFMessageComposeViewController.canSendText() {
let urlToShare = self.referalmodeldata[0].referralCodeOnly
controller1.body = "Hey I just gave an Awesome Assessment on App you can also try it. I scored , Try to beat my score \(String(describing: urlToShare))"
controller1.messageComposeDelegate = self as? MFMessageComposeViewControllerDelegate
self.present(controller1, animated: true, completion: nil)
}
}
You haven't implemented
MFMessageComposeViewControllerDelegatecorrectly in your code.First of all you need to confirm
MFMessageComposeViewControllerDelegatewith yourUIViewControlleras shown below:Next thing is you need add it's delegate method as shown below:
Then you need to replace
with
Demo code will be: