How do I share expo screenshot using react native's share method?

Is it possible I can use expo’s screenshot and share it using the default react native share method

 sharePost= () => {
      message: `Hey look at this screenshot`,
      url: Expo.takeSnapshotAsync(),
      title: `Screen Shot`
    }, {
      dialogTitle: 'Share your screenshot',

Yes. You can do this, but the URL you’ll get from Expo.takeSnapshotAsync() is going to be a local URL on your phone’s filesystem.

To share it effectively using that share method, you’d need to upload to a cloud service and then share that URL. The recipient of your share won’t be able to load the local URL on your phone.

@ccheever How did this project do it :

@bacon - can you chime in here?

1 Like

Firstly, this is how I screenshot in pillar valley and this is how I share it. Unrelated but checkout how I remove useless share props like airdrop, when you do this it makes the share sheet open instantly instead of having that annoying 500ms lag.

Anyways, @amansahil

Will not work because Expo.takeSnapshotAsync() is an async function, meaning that it returns a Promise which you must first resolve.

const url = await Expo.takeSnapshotAsync()

Notice: the await will turn the Promise into a localUri (file://) which you can then share.

Three more important things to note are:

  1. Screenshots must reference the view they are saving
  2. You cannot screenshot GLViews on Android until v26
  3. The url prop isn’t supported in Android

@bacon Thanks mate , this worked amazingly and thanks for the tip , removed the unnecessary options. So any workaround for android ?

1 Like

For the screenshot, you’ll have to wait until v26. To share, you can pass the url to the message prop I think.

1 Like

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