Is it possible I can use expo’s screenshot and share it using the default react native share method
sharePost= () => {
Share.share({
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 : Expo
@bacon - can you chime in here?
1 Like
bacon
March 13, 2018, 6:41pm
6
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:
Screenshots must reference the view they are saving
You cannot screenshot GLViews on Android until v26
The url prop isn’t supported in Android
3 Likes
@bacon Thanks mate , this worked amazingly and thanks for the tip , removed the unnecessary options. So any workaround for android ?
1 Like
bacon
March 14, 2018, 9:10am
8
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
system
Closed
March 29, 2018, 9:11am
9
This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.