I'm building an iOS app that manages audio files. It includes a share extension to receive audio files from other apps. It also can share its audio files with other apps.
When a share is initiated from my app, I do not want my own app to appear in the share sheet. In other words, I do not want the user to send my own audio file back to my app.
I cannot find a way to exclude my own app with an NSExtensionActivationRule.
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
is your Application group identifier:
and then while presenting activityViewController use code below:
let activityViewController = UIActivityViewController(activityItems: [/* Other Items To Share, */ ActionExtensionBlockerItem()], applicationActivities: nil)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With