我想做与苹果文档中解释本文相同的事情,但在 Appcelerator Titanium 中。我搜遍了Appcelerator网站,没有找到方法。有谁知道吗? https://developer.apple.com/library/content/qa/qa1587/_index.html
最佳答案
您需要在 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>
然后,在您的应用程序代码中,每次 resume
事件被触发(例如 Ti.App.addEventListener('resume', resume);
),您可以查看 Ti.App.getArguments().url
查看您的应用程序是否已通过其他应用程序打开。在我的应用程序中,我这样做,并且扫描 Inbox
文件夹看看有没有东西。当另一个应用程序在您的应用程序中打开文档时,它将被复制到此目录中,然后启动您的应用程序。所以Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, 'Inbox').getDirectoryListing() || []
将为您提供其中所有文档的数组,然后您可以将其移出该目录,或处理和删除。
关于ios - 如何让我的应用程序显示在“打开于...”菜单中。加速器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44758681/