简体   繁体   中英

UIActivityViewController, iOS, swift

Do I need to show my App in UIActivityViewController for my another application without the usage of Extension? Is it possible?

And also need when i tapped on other app which are shown in UIActivity ViewController that transfer me into that app.(If is it Possible?)

I have already looked at the following SO Thread I need to show my App in UIActivityViewController for All Applications as Action Extension(Default) , but this is done by extension.

For eg, In iOS 11.0 and above version it give myfile application which shows the files.In this files when I tapped on pdf it shows the own pdfviewer but when i tapped on share button it provide me another added pdfviewer to read and other function which are supported by that application and transfer me to that app.

Is it possible with Action Extension?

Thank You.

It depends whether you want to receive documents or data.

If you want to be listed for Open In or Copy To, as for a document type like PDF, then just declare in the Info.plist that you are a viewer for that document type.

Otherwise to receive data directly thru an activity view, use an Action or Share extension to be listed in the activity view.

Finally I got the answer

When I use UIDocumentInteractionController this is showing me my other app which are support "pdf" and add the property in info.plist which are provided by @matt.

Below code used in parent app so when touch button it shows result like below image. This is my code:-

@IBAction func ShareDocAction(_ sender : UIButton){

    let fileUrl = Bundle.main.url(forResource: "Terms_Condition", withExtension: "pdf")
    self.documentController = UIDocumentInteractionController(url: fileUrl!)

    DispatchQueue.main.async {
        self.documentController.presentOptionsMenu(from: self.actionButton.frame, in: self.view, animated: true)
    }
}

and in child app we need to add below code in info.plist:-

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeName</key>
        <string>PDF Document</string>
        <key>CFBundleTypeRole</key>
        <string>Viewer</string>
        <key>LSHandlerRank</key>
        <string>Alternate</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>com.adobe.pdf</string>
        </array>
    </dict>
</array>

Here I attach my image show whole scenario

在此处输入图片说明

Thank you

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM