import image email attachment into app

I am trying to import email attachments into my iphone app. I am placing code in my info.plist with uti etc. I have successfully imported audio attachments (caf, aifc, aif, m4a, and mp3). But I am not being successful at all with image files. I want to import jpg, jp2, pic, tif, and png files.

I have written this code in my info.plist for the audio files.


Code:


<dict>

<key>LSItemContentTypes</key>

<array>

<string>com.apple.coreaudio-format</string>

</array>

<key>CFBundleTypeRole</key>

<string>Viewer</string>

<key>CFBundleTypeName</key>

<string>.caf</string>

<key>LSHandlerRank</key>

<string>Alternate</string>

</dict>

as I said this works fine for all the audio types I want.

But when I enter this code


Code:


<dict>

<key>LSItemContentTypes</key>

<array>

<string>public.png</string>

</array>

<key>CFBundleTypeRole</key>

<string>Viewer</string>

<key>CFBundleTypeName</key>

<string>.png</string>

<key>LSHandlerRank</key>

<string>Alternate</string>

</dict>


for the images, nothing happens. The app icon doesn't show up in the modal view to tap and "open in" my app.

can anyone see any thing I am doing wrong here?


I have looked at what there is about this and nothing seems to suggest that you need to do any thing different for images than for audio files.

I appreciate any and all help.

iPhone 5, iOS 6.1.2

Posted on Mar 14, 2013 11:09 PM

Reply
10 replies

Mar 18, 2013 5:36 PM in response to Gary Benna

So I don't know if this is possible. On every discussion forum I have found noone who has done this.

I have even copy and pasted Apple's own code


<key>UTExportedTypeDeclarations</key>

<array>

<dict>

<key>UTTypeIdentifier</key>

<string>public.jpeg</string>

<key>UTTypeReferenceURL</key>

<string>http://www.w3.org/Graphics/JPEG/</string>

<key>UTTypeDescription</key>

<string>JPEG image</string>

<key>UTTypeIconFile</key>

<string>public.jpeg.icns</string>

<key>UTTypeConformsTo</key>

<array>

<string>public.image</string>

<string>public.data</string>

</array>

<key>UTTypeTagSpecification</key>

<dict>

<key>com.apple.ostype</key>

<string>JPEG</string>

<key>public.filename-extension</key>

<array>

<string>jpeg</string>

<string>jpg</string>

</array>

<key>public.mime-type</key>

<string>image/jpeg</string>

</dict>

</dict>

</array>

into my info.plist and it doesn't work.


Apparently even Apple doesn't know how to get this to work.

Mar 18, 2013 9:26 PM in response to msuper69

I put the above code into my apps info.plist although I did change <key>UTExportedTypeDeclarations</key> to <key>UTImportTypeDeclarations</key>


and then in the app delegate I am putting


-(BOOL)application:(UIApplication *)application

openURL:(NSURL *)url

sourceApplication:(NSString *)sourceApplication

annotation:(id)annotation {

if (url != nil && [url isFileURL]) {

// do something with the URL

}

returnYES;

}


and then this;



- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{

NSURL *url = (NSURL *)[launchOptions valueForKey:UIApplicationLaunchOptionsURLKey];

if (url != nil && [url isFileURL]) {

//it has been suggested that I put [self.viewcontroller handleOpenURL:url];

or self.window.rootViewController hanleOpenURL:url];


but neither work so I left them out.

}


returnYES;

}


I have also use the code:


<key>CFBundleDocumentTypes</key>

<array>

<dict>

<key>CFBundleTypeName</key>

<string>.jpg</string>

<key>CFBundleTypeRole</key>

<string>Viewer</string>

<key>LSHandlerRank</key>

<string>Alternate</string>

<key>LSItemContentTypes</key>

<array>

<string>public.jpeg</string>

</array>

</dict>

<dict>

<key>CFBundleTypeName</key>

<string>.au</string>

<key>CFBundleTypeRole</key>

<string>Viewer</string>

<key>LSHandlerRank</key>

<string>Alternate</string>

<key>LSItemContentTypes</key>

<array>

<string>public.ulaw-audio</string>

</array>

</dict>

<dict>

<key>CFBundleTypeName</key>

<string>.aiff</string>

<key>CFBundleTypeRole</key>

<string>Viewer</string>

<key>LSHandlerRank</key>

<string>Alternate</string>

<key>LSItemContentTypes</key>

<array>

<string>public.aiff-audio</string>

</array>

</dict>

<dict>

<key>CFBundleTypeName</key>

<string>.aif</string>

<key>CFBundleTypeRole</key>

<string>Viewer</string>

<key>LSHandlerRank</key>

<string>Alternate</string>

<key>LSItemContentTypes</key>

<array>

<string>public.aifc-audio</string>

</array>

</dict>

<dict>

<key>CFBundleTypeName</key>

<string>.caf</string>

<key>CFBundleTypeRole</key>

<string>Viewer</string>

<key>LSHandlerRank</key>

<string>Alternate</string>

<key>LSItemContentTypes</key>

<array>

<string>com.apple.coreaudio-format</string>

</array>

</dict>

<dict>

<key>CFBundleTypeName</key>

<string>.m4a</string>

<key>CFBundleTypeRole</key>

<string>Viewer</string>

<key>LSHandlerRank</key>

<string>Alternate</string>

<key>LSItemContentTypes</key>

<array>

<string>public.mpeg-4-audio</string>

</array>

</dict>

<dict>

<key>CFBundleTypeName</key>

<string>.mp3</string>

<key>CFBundleTypeRole</key>

<string>Viewer</string>

<key>LSHandlerRank</key>

<string>Alternate</string>

<key>LSItemContentTypes</key>

<array>

<string>public.mp3</string>

</array>

</dict>

</array>


The audio files work great but I cannot get the image files to work. I have tried .png, .tif, .pct, and .jp2 int the latter code. Nothing seems to work.


I don't know what I am doing wrong and I am finding it very frustrating without any help.


Thank you for any assistance you can render.

Mar 19, 2013 11:26 AM in response to Gary Benna

I have found that even when I remove all code pertaining to this in the app delegate, when I hold on an audio attachment in my mail my apps icon shows up and then when I tap on that icon my app is brought to the forground and the audio file is copied to my apps documents directory in the "Inbox" folder. But No matter what I do so far this does not happen for the image files. Really all I want to do is have the image files copied to Inbox so the app can access them in various viewControllers and copy them when needed to other document folders. I know that the user could save them to the photo library and then access them from there but this seems slightly less cumbersome (if it works) and just another avenue.

Mar 21, 2013 1:27 PM in response to Gary Benna

Gary Benna wrote:


I don't really want to be able to view the image in my app just copy it over to the "Inbox". Is this possible?

I guess I am confused when you said:


I am trying to import email attachments into my iphone app


You can't interact withing another app. You can only use URLs and apparently you can't use image URLs in Mail. Apple does feel this could be improved, but they may not have done it yet. I don't know. That is an old post.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

import image email attachment into app

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.