My app inside iMessage UIActivityViewController [duplicate]

☆樱花仙子☆ 提交于 2019-12-17 09:36:27

问题


When I open attached image inside my iMessage and tap on "Share" button, I can see icons of 3rd party apps like "Path" or "Evernote". The question is: How can I add my own app to this list?


回答1:


Instead of a URL scheme you need to add a document type to your app. Try adding the following fragment to your Info.plist:

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeName</key>
        <string>public.jpeg</string>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>LSHandlerRank</key>
        <string>Owner</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>public.jpeg</string>
        </array>
    </dict>
</array>

With this fragment (specifically with the LSItemContentTypes key) you declare that your app is an editor for documents that have the Uniform Type Identifier (UTI) public.jpeg. Because this UTI is declared by the system, I believe it is not necessary that you include the UTI declaration in your app's Info.plist.

You can find all system-declared UTI's in the Apple document titled System-Declared Uniform Type Identifiers. If you are new to UTI you should probably also read the Apple document Uniform Type Identifier Concepts.

Last but not least, don't forget to consult the Information Property List Key Reference to find out what you should specify for the Core Foundation keys CFBundleTypeRole and LSHandlerRank.

BTW: This excellent SO answer also has details about working with UTIs, especially if you ever need to declare your own app-specific UTI.



来源:https://stackoverflow.com/questions/15991990/my-app-inside-imessage-uiactivityviewcontroller

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!