My apps ability to share a PDF to another third party app has broken in iOS 11. It shows the share sheet but when I choose to open it in a different (third-party) app, it simply dismisses the share sheet and does nothing.
Things I've confirmed:
- The delegate methods for willBeginSending and didEndSending are both called
- Opening first party apps like Mail or Notes works fine
- The document picker is still in memory
- Presenting a preview works fine but then the share button from inside the preview still will not open third party apps
- I have also tried using a
UIActivityViewController. Sharing a URL produces the same behavior. Sharing the raw data allows you to "Create a PDF" and then sharing that PDF does actually work (but that user experience sucks).
Has anyone else experienced this or have any ideas on how to fix it?
Here is the full code of an example app that shows the problem. I created it in a new "single view" app. The storyboard only has two buttons hooked up to the two actions.
class ViewController: UIViewController {
var docController: UIDocumentInteractionController!
@IBAction func open(sender: UIButton) {
// self.docController.presentPreview(animated: true)
self.docController.presentOptionsMenu(from: sender.frame, in:self.view, animated:true)
}
@IBAction func check() {
print(self.docController)
}
override func viewDidLoad() {
super.viewDidLoad()
let url = Bundle.main.url(forResource: "OrderForm", withExtension: "pdf")!
self.docController = UIDocumentInteractionController(url: url)
self.docController.delegate = self
}
}
extension ViewController: UIDocumentInteractionControllerDelegate {
func documentInteractionControllerViewControllerForPreview(_ controller: UIDocumentInteractionController) -> UIViewController {
return self
}
func documentInteractionController(_ controller: UIDocumentInteractionController, willBeginSendingToApplication application: String?) {
print("will begin")
}
func documentInteractionController(_ controller: UIDocumentInteractionController, didEndSendingToApplication application: String?) {
print("did end")
}
}
I also filed a bug with Apple (Problem ID: 34772214)