Custom UTI does not open in application

I am trying to create a new UTI document for my application so that people can share interests with others. From what I can understand in SO, Tutorials, and Apple documentation, you need to do the following:

  • Create document type in .plist
  • Create an exported UTI that matches it
  • Use the method: - (BOOL) application: (UIApplication * application) didFinishLaunchingWithOptions: (NSDictionary *) launchOptions

As far as I understand, as long as you did this, you should be able to open the file through Mail without any problems. Unfortunately, it does not work for my own UTIs. I see my application in the "Open With ..." list in Mail, but when I select it, my application does not open at all. It just does nothing at all, not only when the application is not open, but when the application is open. Mail remains, and nothing happens at all. I also checked the console using "Organizer" and absolutely nothing happens.

Initially, I thought my plist was wrong, so I tested the opening of a public UTI (I added the document type com.adobe.pdf) and my application started just fine (although it crashed quickly because I did not actually support PDF files;) ) But the fact is that it is launched without any problems.

The only thing I can think about this may be the problem: HOW do I create the file. I create the file by email using this method (also in the export application):

MFMailComposeViewController *picker = [[[MFMailComposeViewController alloc] init] autorelease]; [picker setSubject:[NSString stringWithFormat:@"My place: %@",POIName]]; [picker addAttachmentData:customPOIData mimeType:@"application/customPOI" fileName:[NSString stringWithFormat:@"%@.icp",POIName]]; [picker setMessageBody:@"Check out this great place I found!" isHTML:NO]; [picker setMailComposeDelegate:self]; [self presentModalViewController:picker animated:YES]; 

Is there something wrong with this?

Also, here is my plist code:

CFBundleDocumentTypes:

 <key>CFBundleDocumentTypes</key> <array> <dict> <key>CFBundleTypeIconFiles</key> <array/> <key>CFBundleTypeName</key> <string>Custom POI</string> <key>CFBundleTypeRole</key> <string>Viewer</string> <key>LSHandlerRank</key> <string>Owner</string> <key>LSItemContentTypes</key> <array> <string>com.imadev.icp</string> </array> </dict> </array> 

UTExportedTypeDeclarations:

 <key>UTExportedTypeDeclarations</key> <array> <dict> <key>UTTypeConformsTo</key> <array> <string>public.data</string> </array> <key>UTTypeDescription</key> <string>Custom POI</string> <key>UTTypeIdentifier</key> <string>com.imadev.icp</string> <key>UTTypeTagSpecification</key> <dict> <key>public.filename-extension</key> <array> <string>icp</string> </array> <key>public.mime-type</key> <string>application/customPOI</string> </dict> </dict> </array> 

Thanks for the help! -Mark

+4
source share
2 answers

I finally realized what’s wrong, dividing all the code.

When I change "public.filename-extension" to a string and not an array of strings, it works. Do not ask me why ... It seems strange to me that we cannot use an array of file extensions. But apparently it was so.

Any ideas as to why this happened?

+1
source

In my case, I could save the file extension as an array without problems. Instead, it was a problem with public.data. I switched to "public.image" and then added jpg, jpeg and png as file extensions, and it unexpectedly worked.

0
source

Source: https://habr.com/ru/post/1387596/


All Articles