How to ignore "Import with 'xxx' " in SLComposeViewController

317 Views Asked by At

I make a SLComposeViewController everything works fine until I want to share my Image, there's alot things to click including " import to whatsapp, import to Instagram " and etc.

If I clicked on this my apps will stuck. So I want to exclude all this import things. The question is how can I ? because in UIActivityType. there's no choice of exclude this module

func shareQR(){        
    if filename != nil {
        let imageToShare = [ filename ]
        let activityViewController = UIActivityViewController(activityItems: imageToShare, applicationActivities: nil)
        activityViewController.popoverPresentationController?.sourceView = self.view // so that iPads won't crash

        activityViewController.excludedActivityTypes = [ UIActivityType.airDrop ]

        self.present(activityViewController, animated: true, completion: nil) 
    } 
}

EDIT IMAGE

enter image description here

There's bunch of thing that useless here like "Copy to" & "Import with" I just need like "Instagram" "Whatsapp" and etc.

I need to exclude all of this because it's useless and if this icon clicked will freeze my apps.

1

There are 1 best solutions below

2
Jack On

As of iOS API of UIActivityViewController

@available(iOS 6.0, *)
open class UIActivityViewController : UIViewController {


    public init(activityItems: [Any], applicationActivities: [UIActivity]?)


    @available(iOS, introduced: 6.0, deprecated: 8.0, message: "Use completionWithItemsHandler instead.")
    open var completionHandler: UIKit.UIActivityViewControllerCompletionHandler? // set to nil after call

    @available(iOS 8.0, *)
    open var completionWithItemsHandler: UIKit.UIActivityViewControllerCompletionWithItemsHandler? // set to nil after call


    open var excludedActivityTypes: [UIActivityType]? // default is nil. activity types listed will not be displayed
}

There is no extra methods for excluding share activities (Which is presented on first row), Only user have choice to enable/disable by clicking More on first row then disable switch.