viromedia/viro

Unable to take the screenshot.

kaushallalo opened this issue · 1 comments

Hi,I am trying to take a screenshot but i am getting the following error.

onButtonTap = async () => {
if (!this.state.writeAccessPermission) {
this.requestWriteAccessPermission();
}
try {
await this.ARSceneNav.sceneNavigator.takeScreenshot('kartvya', true).then(result => {
console.log(result.url, 'urlurlurlurlurl');
console.log(result.success, 'successsuccesssuccesssuccesssuccess');
console.log(result.errorCode, 'errorCodeerrorCodeerrorCodeerrorCode');
});
} catch (error) {
console.log(error, 'errorerrorerrorerrorerror');
}
};

<TouchableOpacity
style={{justifyContent: 'center'}}
onPress={this.onButtonTap}>
Capture

Screenshot 2022-10-13 at 9 24 00 AM

skizzo commented

This can be achieved by using react-native-view-shot, by wrapping your ViroARSceneNavigator in a ViewShot and then calling the captureRef() method on said ViewShot.

In the latest version, this also works for Android, just be sure to set the handleGLSurfaceViewOnAndroid option to true, otherwise the screenshot will just be a fully black image.