0

I would like to show only mail, imessages and whatsapp in uiactivitycontroller.
Exclude activity types only excludes default types and shows others.

Is there a way to show only the above mentioned activity.

Thanks in advance

1 Answers1

0

Just Add a method named shouldExcludeActivityType to UIActivityViewController and return false for the activity items you want show and return true for the rest of the items.

import UIKit

class MyActivityViewController: UIActivityViewController {

    func _shouldExcludeActivityType(activity: UIActivity) -> Bool {
        let activityTypesToExclude = [
        "com.apple.mail",
        "com.apple.iMesaage",
         "Whatsapp bundle id"
        ]

        if let actType = activity.activityType() {
            if activityTypesToExclude.contains(actType)       {
                return false
            }
        }
        return true
    }

}
Prakash Shaiva
  • 1,047
  • 8
  • 12