【问题标题】:How do I get my application to show up in the Open in... menu. Appcelerator如何让我的应用程序显示在 Open in... 菜单中。加速器
【发布时间】:2017-11-29 05:34:41
【问题描述】:

我想做与在苹果文档中解释本文相同的事情,但在 Appcelerator Titanium 中。我搜索了 Appcelerator 网站并没有找到方法。有人知道吗? https://developer.apple.com/library/content/qa/qa1587/_index.html

【问题讨论】:

    标签: ios types titanium appcelerator document


    【解决方案1】:

    您需要在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() || [] 会给你一个包含所有文档的数组,然后你可以将其移出该目录,或者处理和删除。

    【讨论】:

    • 非常感谢,我已将您的示例改编为我的应用程序,将类型更改为 jpg、png 和 gif,效果很好。
    • 好!那是一个需要弄清楚的问题,尤其是关于在Inbox 中查找文件的部分。 (我不敢看这是否是推荐的做法,因为它工作得很好!)
    猜你喜欢
    • 1970-01-01
    • 2018-07-28
    • 2011-12-18
    • 1970-01-01
    • 2011-04-28
    • 2017-12-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多