Откройте приложение смс с текстом и URL-адресом в быстром с помощью MFMessageComposeViewController - PullRequest
0 голосов
/ 01 марта 2019

Привет, я хочу открыть приложение смс с соской вдоль URL. Я пишу следующий код, но я сталкиваюсь с ошибкой

, например: Статический член 'canSendText' не может использоваться на экземпляре типа 'MFMessageComposeViewController'

var controller1 = MFMessageComposeViewController()
    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {

            if indexPath.section == 0
            {
                if (controller1.canSendText()) {

                    let urlToShare = "http://www.appzoy.com"

                    controller1.body = "Hey I just gave an Awesome Assessment on UAssess App you can also try it. I scored , Try to beat my score \(urlToShare)"

                    controller1.messageComposeDelegate = self as? MFMessageComposeViewControllerDelegate
                    self.present(controller1, animated: true, completion: nil)
                }
            }
    }

Ответы [ 2 ]

0 голосов
/ 01 марта 2019

Попробуйте это

//MARK:- Send Mail
//MARK:-

func sendMail(emailTitle : String , messageBody : String , toRecipents : [String]){

    if (MFMailComposeViewController.canSendMail()) {

        let mc: MFMailComposeViewController = MFMailComposeViewController()
        let emailTitle = emailTitle //Feedback
        let messageBody = messageBody //"Feature request or bug report?"
        let toRecipents = toRecipents //["friend@stackoverflow.com"]
        mc.mailComposeDelegate = self
        mc.setSubject(emailTitle)
        mc.setMessageBody(messageBody, isHTML: false)
        mc.setToRecipients(toRecipents)
        self.present(mc, animated: true, completion: nil)

    }else{
        //Show alert
    }
}

Функция sendMail для вызова

let urlToShare = "http://www.appzoy.com"
        self.sendMail(emailTitle: "Title of Mail", messageBody: "Hey I just gave an Awesome Assessment on UAssess App you can also try it. I scored , Try to beat my score \(urlToShare)", toRecipents: ["abc@mail.com", "def@mail.com"])
0 голосов
/ 01 марта 2019

Как уже упоминалось в документ , вы должны использовать:

if MFMessageComposeViewController.canSendText() {
    print("SMS services are available")
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...