Search code examples
iosswiftpdfsafariios-app-extension

Swift - App Extension to open PDF files


I want my app to be able to copy PDF files from Safari, just like adobe reader can copy them from Safari.

Is this a private API that adobe reader uses? I can't find any guide about such action and by reading apple documentation I became more confused and now I have no idea if I need to use a UIActivityViewController or a UIDocumentInteractionController.


Solution

  • You need to look into the Document Interaction API

    You should specifically look into the Registering Your Support of File Types and Opening Files From Other Apps sections.

    Once you've registered PDF as a file type your app supports, your app will appear in the list that shows when you press the More... button.

    • If your app is the only app that can open PDFs, it will appear instead of "Adobe Acrobat" on the right.
    • If you have multiple apps that can open PDFs on your phone, iOS will choose one, but you have no control over which one. Even the user has no control over which one.