Share images from Dropbox/Google Photos into Expo app?

I may have reached the point where I have to detach my Expo project. I need to add my app to the drawer of “sharing options” when choosing to share an asset type from inside a third party library.

From inside the camera roll app, for example, I could click an image, then click share, and get something like:

This would launch the Expo app and run some handler function.

I found this issue on GitHub and commented:

https://github.com/expo/expo/issues/48#issuecomment-373375453

One of the maintainers has stated: “There is no native share extension API”, so I assume this is pretty much a case-closed issue.

I am wondering two things:

1. Has anyone run into this before, and found a way around it without detaching?
2. How do you do this in vanilla RN, anyways (not the best question for this forum)?

Thanks!

I’m assuming you’ve seen the docs on adding this feature: Technical Q&A QA1587: How do I get my application to show up in the Open in... menu. in which Apple walks you through how to get a UTI (:joy:)


If you wanna play with my thoughts, here they are:

I’ll only cover iOS as I’ve only ever done this on native iOS.

You mostly need access to the info.plist - supported
Then add support for your favorite file types!
info.plist

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeIconFiles</key>
        <array>
            <string>Document-molecules-320.png</string>
            <string>Document-molecules-64.png</string>
        </array>
        <key>CFBundleTypeName</key>
        <string>Molecules Structure File</string>
        <key>CFBundleTypeRole</key>
        <string>Viewer</string>
        <key>LSHandlerRank</key>
        <string>Owner</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>com.sunsetlakesoftware.molecules.pdb</string>
            <string>org.gnu.gnu-zip-archive</string>
        </array>
    </dict>
</array>
<key>UTExportedTypeDeclarations</key>
<array>
    <dict>
        <key>UTTypeConformsTo</key>
        <array>
            <string>public.plain-text</string>
            <string>public.text</string>
        </array>
        <key>UTTypeDescription</key>
        <string>Molecules Structure File</string>
        <key>UTTypeIdentifier</key>
        <string>com.sunsetlakesoftware.molecules.pdb</string>
        <key>UTTypeTagSpecification</key>
        <dict>
            <key>public.filename-extension</key>
            <string>pdb</string>
            <key>public.mime-type</key>
            <string>chemical/x-pdb</string>
        </dict>
    </dict>
</array>

Which maybe translates to this:

app.json

{
  "ios": {
    "infoPlist": {
      "CFBundleDocumentTypes": [
        {
           "CFBundleTypeIconFiles": [
            "Document-molecules-320.png",
            "Document-molecules-64.png"
          ],
          "CFBundleTypeName": "Molecules Structure File",
          "CFBundleTypeRole": "Viewer",
          "LSHandlerRank": "Owner",
          "LSItemContentTypes": [
            "com.sunsetlakesoftware.molecules.pdb",
            "org.gnu.gnu-zip-archive"
          ],
        }
      ],
      "UTExportedTypeDeclarations": [
        {
          "UTTypeConformsTo": [
            "public.plain-text",
            "public.text"
          ],
          "UTTypeDescription": "Molecules Structure File",
          "UTTypeIdentifier": "com.sunsetlakesoftware.molecules.pdb",
          "UTTypeTagSpecification": {
            "public.filename-extension": "pbd",
            "public.mime-type": "chemical/x-pdb"
          }
        },
      ]
    }
  }
}

LSItemContentTypes : is a pain so maybe experiment with this in a native project.
CFBundleTypeIconFiles : I have no clue how we’d do this one but maybe a script or something can compile a local image asset.

Finally when the user opens your app, you need to get the file - not sure about this one.
This is done through an AppDelegate method called application:openURL:sourceApplication:annotation
It looks like we do something with this but I’m not sure where you access that. (I didn’t really look :upside_down_face:)

If also looks like depending on the state of the app, the file might be open and passed to application:didFinishLaunchingWithOptions instead!

This is also made confusing by the addition of the files app in ios - I’m not sure how it plays into this exact feature but let’s say it did :sweat_smile:you would add this key to your app.json ios.infoPlist.UIFileSharingEnabled: true

Anyways, this is a tricky topic that is very platform specific so Expo probably won’t support soon… probs detach.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.