3

I am building an iOS app that I would like to receive shared content from other apps, e.g. Safari web URLs, pasted text etc that the user has shared, either from the Share sheet or from the selected text "Share" button.

My app doesn't seem to appear in the Share sheet at all, except if I specify "com.adobe.pdf" in my info.plist

I've tried:

  • public.url
  • public.content
  • public.data

Here is the entry in my info.plist:

<key>CFBundleDocumentTypes</key>
  <array>
    <dict>
      <key>CFBundleTypeName</key>
      <string>PDF</string>
      <key>CFBundleTypeRole</key>
      <string>Viewer</string>
      <key>LSHandlerRank</key>
      <string>Alternate</string>
      <key>LSItemContentTypes</key>
      <array>
        <string>com.adobe.pdf</string>
        <string>public.url</string>
        <string>public.url-name</string>
        <string>public.html</string>
        <string>public.content</string>
        <string>public.data</string>
      </array>
    </dict>
  </array>

I have also tried adding the CFBundleURLTypes key with the following content (With both CFBundleTypeRole set as Editor and Viewer):

    <key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleURLName</key>
            <string>HTTPS</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>https</string>
            </array>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
        </dict>
        <dict>
            <key>CFBundleURLName</key>
            <string>HTTP</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>http</string>
            </array>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
        </dict>
    </array>
</dict>

Where am I going wrong? Do I need to write a Share Extension to receive URLs, paste text etc?

Thanks in advance

Chris

Chris Roberts
  • 476
  • 3
  • 8
  • Check https://developer.apple.com/library/archive/documentation/Miscellaneous/Reference/UTIRef/Articles/System-DeclaredUniformTypeIdentifiers.html – Lucas Zhang Jul 22 '19 at 13:02
  • Thanks @LucasZhang-MSFT I used the public.url and other UTIs from that page to build my info.plist entry, doesn't seem to be working – Chris Roberts Jul 22 '19 at 13:12
  • Did you override the method `OpenUrl` ? – Lucas Zhang Jul 22 '19 at 13:17
  • I did yes. I can see my app in the share sheet for PDF files (com.adobe.pdf) and the OpenUrl method is called for that type – Chris Roberts Jul 22 '19 at 14:19
  • You can share a sample which contains your issue so that I can test it on my side . – Lucas Zhang Jul 23 '19 at 07:06
  • Thanks for your help @LucasZhang-MSFT. I've created a sample project here https://github.com/chrismroberts/share-target-example. The com.adobe.pdf UTI works fine, I can share a PDF file and hit the breakpoint in AppDelegate,but the app doesn't appear on the Share Sheet for other types (e.g. website URL). – Chris Roberts Jul 23 '19 at 13:02
  • I checked your sample and It seeems that you missing some `type` in your info.plist. And you can refer this similar issue https://stackoverflow.com/questions/30452686/app-is-not-showing-in-the-share-menu-of-shared-options-in-shared-extension-in-io . – Lucas Zhang Jul 31 '19 at 00:53

0 Answers0