隐藏或删除应用内的共享扩展

时间:2019-07-27 09:26:25

标签: ios swift

我正在开发共享扩展名,它可以正常工作,但是我想在应用程序内隐藏共享扩展名,因为无法进行应用程序到应用程序的共享。有什么解决办法吗?请帮忙。

1 个答案:

答案 0 :(得分:0)

自定义活动项的来源

class ActionExtensionBlockerItem: NSObject, UIActivityItemSource {
    func activityViewController(_ activityViewController: UIActivityViewController, dataTypeIdentifierForActivityType activityType: UIActivityType?) -> String {
        return "your.unique.com";//OR any String
    }
    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 ""
    }
}

var objectsToShare = [Any]()
objectsToShare.append("Example text")
 //add your objects
 objectsToShare.append(ActionExtensionBlockerItem())//for hide share extention
let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil)
self.present(activityVC, animated: true, completion: nil)