0

I'm developing a custom UTI like "com.xyz".

All the apps supporting this UTI may be shown in the UIActivityViewController.

Code snippet:

let extensionItem = NSExtensionItem()

let data = NSItemProvider.init(item: nil, typeIdentifier: "com.xyz")
extensionItem.attachments = [data]

let activity = UIActivityViewController(
    activityItems: [extensionItem],
    applicationActivities: nil
)
present(activity, animated: true, completion: nil)

In order to have a better user experience, I would like to check if the iOS device has any App supporting "com.xyz" before presenting the UIActivityViewController.

Just like check URL:

UIApplication.shared.canOpenURL(URL(string: urlStr)!)

Otherwise the user may see an empty UIActivityViewController without any app.

As I know, there is an ActivityNotFoundException could be try and catch to handle the app not found situation in Android. Does iOS support something like ActivityNotFoundException?

THANKS!

empty UIActivityViewController

TylerP
  • 9,600
  • 4
  • 39
  • 43
  • If the UTI is custom, how can _any_ other app support it? You are supposed to provide unique UTI string; the whole idea is that _no_ other app should ever have heard of it. Otherwise it's not custom. – matt May 14 '20 at 02:15
  • Yes, The idea is that i provide the UTI "com.xyz" to the other. if the iOS device currently is no app supporting "com.xyz". I hope to present an alertController that recommends user to download any app supporting "com.xyz". – RCDeveloper May 14 '20 at 02:31
  • But how can there be one if you just invented it? – matt May 14 '20 at 02:34
  • For instance, the UTI is "com.adobe.pdf" but the iOS device currently does have any app support "com.adobe.pdf". Could i know it before present the UIActivityViewController? – RCDeveloper May 14 '20 at 02:51
  • But com.adobe.pdf is not “custom”. It is just the opposite. It is a well known official UTI. – matt May 14 '20 at 11:10
  • Ok, Then i revise the question into "Could i check UTI 'com.adobe.pdf' supported app in iOS device before presenting the UIActivityViewController ?" – RCDeveloper May 18 '20 at 08:12

0 Answers0