takeSnapshotAsync not working

Please provide the following:

  1. SDK Version:33
  2. Platforms(Android/iOS/web/all):Android/iOS

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…

Make sure you have requested Camera Roll permissions before you try to save to the camera roll.

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.

I created an example for you here that works: https://snack.expo.io/@salus/take-snapshot-of-screen,-save-to-camera-roll

1 Like

I checked it and working well.
Thank you very much.

1 Like

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