Javad
Javad

Reputation: 43

iOS : activityType doesn't work on UIactivityViewController

hi this is my code I have implement UIactivityViewCotroller but when I click I don't see mail and Facebook app

@IBAction func activityView(_ sender: UIButton) {
    let text = "This is some text that I want to share."
    let textToShare = [ text ]
    let activityViewController = UIActivityViewController(activityItems: textToShare, applicationActivities: nil)
    activityViewController.popoverPresentationController?.sourceView = self.view
    activityViewController.excludedActivityTypes = [ UIActivityType.airDrop, UIActivityType.postToFacebook, UIActivityType.mail ]
    self.present(activityViewController, animated: true, completion: nil)
}

but I don't see those app what should I do?

Upvotes: 0

Views: 704

Answers (1)

Amal T S
Amal T S

Reputation: 3405

Replace the function as follows

@IBAction func activityView(_ sender: UIButton) {
    let text = "This is some text that I want to share."
    let textToShare = [ text ]
    let activityViewController = UIActivityViewController(activityItems: textToShare, applicationActivities: nil)
    activityViewController.popoverPresentationController?.sourceView = self.view
        activityViewController.excludedActivityTypes = [ UIActivityType.airDrop ]
    self.present(activityViewController, animated: true, completion: nil)
}

Activity Controllers excludedActivityTypes means you are excluding those sharing options to list in activityController

Upvotes: 1

Related Questions