gre / react-native-view-shot

Snapshot a React Native view and save it to an image
https://github.com/gre/react-native-view-shot-example
MIT License
2.67k stars 346 forks source link

Getting "This file type is not supported yet." on iOS simulator #433

Closed amandeepmittal closed 2 years ago

amandeepmittal commented 2 years ago

bug report

Hi, I'm using react-native-view-shot and it works fine on both iOS and Android devices. But when I'm running my example on iOS simulator I am getting the following warning/error:

iOS Running app on iPhone 13
/Users/username/Library/Developer/CoreSimulator/Devices/7C9DD290-834F-426D-A774-EBD583305F84/data/Containers/Data/Application/C5EC31DB-A654-48DF-9F42-5864DF16257B/tmp/ABI45_0_0ReactNative/75FEFCC8-43A5-4EE6-8567-B5877A56E01B.png

This file type is not supported yet.
at node_modules/react-native/Libraries/BatchedBridge/NativeModules.js:106:50 in promiseMethodWrapper
at node_modules/expo-modules-core/build/NativeModulesProxy.native.js:15:23 in moduleName.methodInfo.name
at node_modules/expo-media-library/build/MediaLibrary.js:168:17 in saveToLibraryAsync
at node_modules/expo-media-library/build/MediaLibrary.js:164:7 in saveToLibraryAsync
at App.js:157:14 in saveAsImage

Version & Platform

├─┬ react-native-reanimated@2.8.0
│ └── react-native@0.68.2 deduped
├─┬ react-native-view-shot@3.1.2
│ └── react-native@0.68.2 deduped
└─┬ react-native@0.68.2
  └─┬ @react-native-community/cli@7.0.4
    └── react-native@0.68.2 deduped

Platform: iOS simulator 13(iOS 15.5)

Expected behavior

I can see that the file does save inside the CoreSimilator location but it doesn't appear on iOS simulator media library. Is this the expected behaviour on an iOS simulator?

Actual behavior

This might not be a bug so I am just trying to confirm if the expected behaviour is how it is done on iOS simulator?

Steps to reproduce the behavior

I'm using the library with Expo SDK 46 and using expo-media-library package to save the captured image.

Here is my code snippet:

const imageRef = useRef();

const saveAsImage = async () => {
      try {
        const localUri = await captureRef(imageRef, {
          width: 356,
          height: 522,
          quality: 1,
          format: "png",
        });
        console.log(localUri);
        await MediaLibrary.saveToLibraryAsync(localUri);
      } catch (e) {
        console.log(e);
      }
gre commented 2 years ago

This may be more a topic for Expo.

amandeepmittal commented 2 years ago

Okay, thanks for taking a look at this. I'll close this one.