4

I would like to disable Messenger from UIActivityViewController options. I know that there is excludedActivityTypes attribute which I can exclude some activities from showing. It's working fine and I disable what I want. But I still have Messenger in my share options and that is what I want to exclude too. I am not sure how to do it. Could I disable it by setting one more UIActivityType with rawValue? What would be rawValue for Messenger Share Extension? Thanks for help

  vc.excludedActivityTypes = [
    UIActivityType.postToWeibo,
    UIActivityType.print,
    UIActivityType.copyToPasteboard,
    UIActivityType.addToReadingList,
    UIActivityType.assignToContact,
    UIActivityType.print,
    UIActivityType.message,
    UIActivityType.mail,
    UIActivityType.airDrop,
    UIActivityType.postToFlickr,
    UIActivityType.postToVimeo,
    UIActivityType.postToFacebook,
    UIActivityType.postToTwitter,
    UIActivityType.postToTencentWeibo,
    UIActivityType.airDrop,
    UIActivityType.assignToContact,
    UIActivityType(rawValue: "com.apple.reminders.RemindersEditorExtension"),
    UIActivityType(rawValue: "com.apple.mobilenotes.SharingExtension"),
    UIActivityType(rawValue: "?")]
Libor Zapletal
  • 13,752
  • 20
  • 95
  • 182

1 Answers1

3

You can exclude Facebook Messenger using

UIActivityType(rawValue: "com.facebook.Messenger.ShareExtension")

if you need to check which sharing type did the user used you can do

let activityVC = UIActivityViewController(activityItems: [message, "\n", URL(string:link) as Any], applicationActivities: nil)

activityVC.completionWithItemsHandler = { activity, success, items, err in
    if !success {
        print("SHARE ABORTED")
        return
    }
    if activity == UIActivityType.postToFacebook {
        print("SHARE TO FACEBOOK")
    }

    if activity == UIActivityType.init(rawValue: "net.whatsapp.WhatsApp.ShareExtension") {
       print("SHARE TO Whatsapp")
     }

    if activity == UIActivityType.init(rawValue: "com.facebook.Messenger.ShareExtension") {
        print("SHARE TO FB MESSENGER")
     }
}
Kegham K.
  • 1,589
  • 22
  • 40