Hello.
I am going to take a screenshot for share image to facebook and twitter.
So I used takesnapshot function on expo.
But I can not get screenshot.
Please let me know how to fix it.
Thank you.
import * as Expo from 'expo';
…
_saveToCameraRoll = async() => {
let ss = Expo.takeSnapshotAsync(this._container, {
format: 'png',
result: 'file',
});
let saveResult = CameraRoll.saveToCameraRoll(ss, 'photo');
this.setState({ snapshot: saveResult });
}
Now I am getting undefined value on console.
I am testing it on android emulator…
After that, CameraRoll.saveToCameraRoll should work.
Note too that takeSnapshotAsync is an async function, so you need to await it: let ss = await Expo.takeSnapshotAsync(...
You’ll also want to wrap that in a try/catch.
Finally, it looks like takeSnapshotAsync has been removed at some point (SDK 34 or 35 maybe?), even though the documentation was never updated. The only reference to this I could find was this GitHub issue, which mentions that it’s been replaced with react-native-view-shot.
If adding in the Permissions request and await don’t fix it for you, try also using expo install react-native-view-shot to move to that library instead.