Retrieving a file from e-mail

You must Login before you can answer or comment on any questions.

I want to register a file type with the IOS system and have my users be able to open the file from e-mail and feed it to my titanium program. I've seen a few people ask this question, but no answers. Can this be done in titanium?

— asked 10 months ago by Stephen Flournoy
1 Comment
  • I have the same problem, did you find an answer ?

    — commented 9 months ago by Gregory Brauge

4 Answers

This can absolutely be done.

You need to add information into the apps info.plist file. The instructions are readily available via Google.

Here is an example from one of my apps that opens PDF files from an email.

<key>CFBundleDocumentTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeIconFiles</key>
            <array>
                <string>Icon.png</string>
            </array>
            <key>CFBundleTypeName</key>
            <string>Open PDF in AppName</string>
            <key>CFBundleTypeRole</key>
            <string>Viewer</string>
            <key>LSHandlerRank</key>
            <string>Alternate</string>
            <key>LSItemContentTypes</key>
            <array>
                <string>com.adobe.pdf</string>
            </array>
        </dict>
    </array>

Thanks Tim! I'll check this out. Where does the file go once you "open" it in your titanium app?

— answered 9 months ago by Stephen Flournoy
answer permalink
1 Comment
  • The file is passed into the apps inbox ... you can get the file name from the event ... here is some code from my app

    App.f.processArguments = function(_url) {
            try {
     
                var args = Titanium.App.getArguments();
                App.pendingJob = null;
                if (args.url !== undefined && args.url !== App.url){
     
                     //App.url is saved so we don't process the same file 
                    App.url =  args.url;
     
                    //Do Something
                }

    — commented 9 months ago by Tim Alosi

I need to do the inverse operation: I want to create a button (or menu) in my app that check if adobe reader is installed and open the document in adobe reader. I need to check which applications have registered the com.adobe.pdf key in CFBundleDocumentTypes. Is it possible in titanium?

There is a module in the market place that allows you to provide the "open in" menu functionality in your app. It is called DocumentViewer for iPhone.

Check it out ... I think it will do what you need.

Your Answer

Think you can help? Login to answer this question!