我试图通过whatsapp在一条消息中发送音频剪辑和网址。
我使用以下代码发送音频:
let activityItem = URL.init(fileURLWithPath: Bundle.main.path(forResource: “Audio1”, ofType: “mp3")!)
let activityVC = UIActivityViewController(activityItems: [activityItem],applicationActivities: nil)
activityVC.popoverPresentationController?.sourceView = self.view
self.present(activityVC, animated: true, completion: nil)
和此代码发送网址:
let urlString = "Visit this website: http://www.google.com"
let urlStringEncoded = urlString.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed)!
let url = NSURL(string: "whatsapp://send?text=\(urlStringEncoded)")
if UIApplication.shared.canOpenURL(url! as URL) {
UIApplication.shared.openURL(url! as URL)
}
我已经尝试了很多东西将它们发送到一起但是还没有能够解决它。有人知道我是否可以同时发送这两个,如果是的话,我该怎么做?