Register custom file type in iOS

I am working on an iOS application in which I want the XML file to be the main input for this application. I started a search trip (mainly on stackoverflow) to find out how I can get XML files from email.

I first found an alternative method that registered the URL format for my files and used it in Email instead of the attached file, and this method works well.

Now I want to use the file itself (attached). I found that I need to register a custom file type in this application, depending on these resources.

related to this, I edited the info.plist file with this code

<key>CFBundleDocumentTypes</key> <array> <dict> <key>CFBundleTypeName</key> <string>XML File</string> <key>CFBundleTypeRole</key> <string>Viewer</string> <key>LSHandlerRank</key> <string>Owner</string> <key>LSItemContentTypes</key> <array> <string>com.IT.parseXML.XML</string> </array> </dict> </array> 

and this part also

 <key>UTExportedTypeDeclarations</key> <array> <dict> <key>UTTypeConformsTo</key> <array> <string>public.text</string> </array> <key>UTTypeDescription</key> <string>XML Document</string> <key>UTTypeIdentifier</key> <string>public.xml</string> <key>UTTypeReferenceURL</key> <string>http://www.w3.org/TR/rec-xml</string> <key>UTTypeTagSpecification</key> <dict> <key>public.filename-extension</key> <array> <string>xml</string> </array> <key>public.mime-type</key> <string>text/xml</string> </dict> </dict> </array> 

I expect that I can process XML files from emails ... but this does not happen, what am I missing?

early

+6
source share
1 answer

I found out the problem in my configuration, he was on this line

 <key>LSItemContentTypes</key> <array> <string>com.IT.parseXML.XML</string> </array> 

he should be

 <key>LSItemContentTypes</key> <array> <string>public.XML</string> </array> 

as in the public identifier

+2
source

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


All Articles