Post

Replies

Boosts

Views

Activity

UIActivityViewController - Share file url from myApp to myApp
What would i do? I would like to be able to share a file url within my own app, like for example Mail does, i.e.: open myApp share content from myApp choose myApp from the list e.g. Mail open a mail take the attached file share the attached file to Mail What am I doing? Starting from a self-generated app from Xcode I guess the key word was CFBundleDocumentTypes. So I added <key>CFBundleDocumentTypes</key> <array> <dict> <key>CFBundleTypeIconFiles</key> <array/> <key>CFBundleTypeName</key> <string>All Files</string> <key>CFBundleTypeRole</key> <string>Editor</string> <key>LSHandlerRank</key> <string>Alternate</string> <key>LSItemContentTypes</key> <array> <string>public.data</string> </array> </dict> </array> to the Info.plist. By doing this myApp is able to receive files from outside (e.g. from Files app). Then I added in the ViewController @IBAction func share(_ sender: Any) { let url = Bundle.main.url(forResource: "blank", withExtension: "pdf")! let activityViewController = UIActivityViewController(activityItems: [url], applicationActivities: nil) if let popover = activityViewController.popoverPresentationController { popover.sourceView = view popover.sourceRect = CGRect(x: view.bounds.midX, y: view.bounds.maxY, width: 0, height: 0) } activityViewController.isModalInPresentation = true present(activityViewController, animated: true) } linked to a Button. The Problem By clicking on the share button myApp does not appear in the list. What's funny? it works on the simulator - Xcode 14.3 RC 2.
0
0
717
Mar ’23