I want to do the same thing that explains this article in the apple documentation, but in Appcelerator Titanium. I searched the Appcelerator website and did not find the way. Anyone know any? https://developer.apple.com/library/content/qa/qa1587/_index.html
You need to register for the files you want to be able to handle in your tiapp.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<ti:app xmlns:ti="http://ti.appcelerator.org">
<ios>
<plist>
<dict>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeName</key>
<string>Add to Housters</string>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>LSHandlerRank</key>
<string>Owner</string>
<key>LSItemContentTypes</key>
<array>
<string>com.adobe.pdf</string>
<string>com.microsoft.word.doc</string>
</array>
</dict>
</array>
</dict>
</plist>
</ios>
</ti:app>
Then, in your application's code, every time the resume
event is fired (for example, Ti.App.addEventListener('resume', resume);
), you can look at Ti.App.getArguments().url
to see if your app has been opened via another app. In my apps, I do that, plus I scan the Inbox
folder to see if there's anything. When another app opens a document in your app, it gets copied in to this directory, and then your app is launched. So Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, 'Inbox').getDirectoryListing() || []
will get you an array of all the documents in there, which you can then move out of that directory, or handle and delete.