Take snapshot of screen does not work

Hi, please excuse my newbie question, but this has bothered me for few days.

I have copied the methods related to taking a screenshot from a working snack into another snack. But it doesn’t work.

Take snapshot of screen, save to camera roll - Snack [this is example of a working screenshot]
Firebase-Upload-Image - Snack [not working example. there are two similar functions - none works]

I really appreciate if you can give me a clue.

Thank you very much! (and I hope i places the question correctly in the forum).

Hi @bkamrani-

First thing, I’d say to take a peek at the docs for the APIs you’re using. You’re using the old import style, which we’ve deprecated, and the docs will show the new ones.

The “working” snack you linked is written in an older SDK, so I’m curious how you’re getting it to work? Are you running it locally on your own device, through expo-cli? If so, you must be using an older version of the Expo client app

1 Like

Hi Charlie, thank you so much for looking into my question!! and pointing out the old SDK.

Yes, I run it locally on my iOS device using expo client app (2.11.1 which I think it’s latest?). On the snack browser, the expo version is set to 33.0.0 (works with 32.0.0 as well).

Any idea what I am doing wrong? thanks!

That is the latest Expo iOS client version, yes

My suggestion is to update your imports, according to the API docs.

So I started to update the imports according the API docs as follow (hopefully I understood it right)

import { Constants, ImagePicker, Permissions } from ‘expo’; //old import
// the following three imports replaces the above old import
// import Constants from ‘expo-constants’;
// import * as ImagePicker from ‘expo-image-picker’;
// import * as Permissions from ‘expo-permissions’;

However, I am getting the following error on Snack when I change any of the above changes.

Device: (1052:881) Unable to resolve module ‘module://@unimodules/core.js’
Evaluating module://@unimodules/core.js
Evaluating module://expo-permissions.js
Evaluating module://App.js.js
Loading module://App.js

So at the end, it seems that I have to stick to the old import. Or what do you suggest?

Beside, it seems that the old import is actually still working as the working example demonstrates. So the issue likely to be something else? Thanks!

Try copy/pasting into a new snack, I’ve seen that error before and that seemed to fix it. Must have just somehow gotten into a bad state with the imports

Yes, I have noticed that sometimes this issue was removed by copy/pasting into a new snack, but unfortunately in this it didn’t help :frowning:

Are you saying that the code has not obvious bug (and should work)?

Yeah, you could also try running it locally with expo-cli rather than through Snack. I don’t believe this is an SDK0-related problem (unless you can provide an example where the same code works on one SDK and doesn’t on another)

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