2017-09-20 28 views
2

我必須將文本和URL共享到消息應用程序。如何使用swift共享Masse應用程序中的Url和文本3

if (MFMessageComposeViewController.canSendText()) { 
     let controller = MFMessageComposeViewController() 

     //controller.subject = "http://www.appzoy.com" 

     //controller.attachments?.append(["url" : URL(string : "http://www.appzoy.com")!]) 

     //controller.addAttachmentURL(URL(string : "http://www.appzoy.com")!, withAlternateFilename: "") 

     controller.body = "Hey I just gave an Awesome Assessment on UAssess App you can also try it. I scored \(String(describing: myScore!)) , Try to beat my score" 

     controller.messageComposeDelegate = self 
     self.present(controller, animated: true, completion: nil) 
    } 

    else { 

     Helper.sharedInstance.Print("No Message Composer Present" as AnyObject) 
    }. 

我試圖通過URL也不過它不會對消息應用 任何人都知道如何共享信息應用程序URL鏈接和文本。

+0

確實想發送文本和網址短信吧? – ivarun

+0

是@ivarun我想發短信和網址爲短信。 – kishor0011

回答

1

試試下面的代碼:

let controller = MFMessageComposeViewController() 

    if (MFMessageComposeViewController.canSendText()) { 

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

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

     controller.messageComposeDelegate = self 
     self.present(controller, animated: true, completion: nil) 
    } 

enter image description here 希望這將幫助你:)

+0

我也是這樣做的。問題是URL鏈接不會來。 – kishor0011

+0

@ kishor0011please檢查截圖 – ivarun

+0

確定讓我再試一次。 – kishor0011

相關問題