13

Is there any way to handle sharing files to expo app? According to the documentation of app.json it's possible to provide intentFilters, but I can't find anything regarding handling them afterwards.

Ejecting is not an option.

Phil Rukin
  • 450
  • 2
  • 17
  • Have you looked at Linking? [Handling links into your app](https://docs.expo.io/versions/latest/workflow/linking/#handling-links-into-your-app). A bit further down it also contains a section about handling data passed to the app. – Maarten Peels Jan 31 '20 at 14:26
  • Yes, I did, but it only gives a url looking like `exp://exp.host/@community/native-component-list`, but no image info – Phil Rukin Jan 31 '20 at 14:36

1 Answers1

-1

The documentation says

To add or edit intent filters in an ExpoKit project, edit AndroidManifest.xml directly.

You can see here how to add an intent filter in the manifest, that define the activity (in the example ShareActivity) that will handle receiving text (you can remove this part) or images

<activity android:name="ShareActivity">
    <!-- This activity handles "SEND" actions with text data -->
    <intent-filter>
        <action android:name="android.intent.action.SEND"/>
        <category android:name="android.intent.category.DEFAULT"/>
        <data android:mimeType="text/plain"/>
    </intent-filter>
    <!-- This activity also handles "SEND" and "SEND_MULTIPLE" with media data -->
    <intent-filter>
        <action android:name="android.intent.action.SEND"/>
        <action android:name="android.intent.action.SEND_MULTIPLE"/>
        <category android:name="android.intent.category.DEFAULT"/>
        <data android:mimeType="application/vnd.google.panorama360+jpg"/>
        <data android:mimeType="image/*"/>
        <data android:mimeType="video/*"/>
    </intent-filter>
</activity>

Then, in your activity in expo.io, you need to get the extra from the Intent and you will have the info of the attached image

Carlos Robles
  • 10,828
  • 3
  • 41
  • 60
  • He's not using Expokit but a managed expo app(And ejecting isn't an option). So this, unfortunately, won't be possible. – Maarten Peels Jan 31 '20 at 14:18
  • I'm not using expokit and I know how to add intent filters(I have a link to docs in a question). What I don't know is how to handle the image from the app. – Phil Rukin Jan 31 '20 at 14:26
  • For example to handle notifications it's possible to add `Notifications.addListener(listener)` and handle notifications in `listener` callback. I was hoping something similar exists for share intents – Phil Rukin Jan 31 '20 at 14:34