Prevent my own app-level extension from being shown in a shared sheet

I am creating an iOS app that manages audio files. It includes an extension to get audio files from other applications. It can also share its audio files with other apps.

When the resource is being initiated from my application, I don't want my own application to appear in the shared sheet. In other words, I don't want the user to send my own audio file back to my application.

I cannot find a way to exclude my application using NSExtensionActivationRule.

+4


source to share


1 answer


Sorry for late, but hope this answer helps you.

First of all define below lines in your code

class ActionExtensionBlockerItem: NSObject, UIActivityItemSource {
func activityViewController(_ activityViewController: UIActivityViewController, dataTypeIdentifierForActivityType activityType: UIActivityType?) -> String {
    return "com.your.unique.uti";
}
func activityViewController(_ activityViewController: UIActivityViewController, itemForActivityType activityType: UIActivityType) -> Any? {
    // Returning an NSObject here is safest, because otherwise it is possible for the activity item to actually be shared!
    return NSObject()
}
func activityViewController(_ activityViewController: UIActivityViewController, subjectForActivityType activityType: UIActivityType?) -> String {
    return ""
}
func activityViewController(_ activityViewController: UIActivityViewController, thumbnailImageForActivityType activityType: UIActivityType?, suggestedSize size: CGSize) -> UIImage? {
    return nil
}
func activityViewControllerPlaceholderItem(_ activityViewController: UIActivityViewController) -> Any {
    return ""
}

      



}

Here com.your.unique.uti - this is the identifier of your application pool see this image for refrence, and then the presentation activityViewController using the code below

let activityViewController = UIActivityViewController(activityItems: [/* Other Items To Share, */ ActionExtensionBlockerItem()], applicationActivities: nil)

      

0


source







All Articles