Guest User

Untitled

a guest
Apr 22nd, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. let activityItem = URL.init(fileURLWithPath: Bundle.main.path(forResource: “Audio1”, ofType: “mp3")!)
  2. let activityVC = UIActivityViewController(activityItems: [activityItem],applicationActivities: nil)
  3. activityVC.popoverPresentationController?.sourceView = self.view
  4. self.present(activityVC, animated: true, completion: nil)
  5.  
  6. let urlString = "Visit this website: http://www.google.com"
  7. let urlStringEncoded = urlString.addingPercentEncoding(withAllowedCharacters: .urlHostAllowed)!
  8. let url = NSURL(string: "whatsapp://send?text=(urlStringEncoded)")
  9.  
  10. if UIApplication.shared.canOpenURL(url! as URL) {
  11. UIApplication.shared.openURL(url! as URL)
  12. }
Add Comment
Please, Sign In to add comment