Get phone orientation at moment picture is taken with cordova-plugin-camera

113 views Asked by At

I have a Cordova app which uses cordova-plugin-camera to take pictures. I need to capture the phone orientation at the instant the picture is taken. I know how to use DeviceOrientation to get the phone orientation, but the problem is that if I capture it before invoking getPicture, the user may move the phone prior to pressing the shutter button, and since I am using the allowEdit option to let the user crop the picture before returning to the app, if I capture the orientation afterwards the user will probably have moved the phone in the course of doing the editing. Is there any way I can capture the orientation at the instant the shutter button is pressed?

1

There are 1 answers

0
jcesarmobile On BEST ANSWER

You can't as if you use allowEdit: true option, as soon as the user accepts the picture, he is taken into the edit screen and all of that is handled by the plugin.

What you can do is to use the correctOrientation: true option, that should take care of the orientation for you.

In case that doesn't work as you like, then you'll have to fork the plugin and add some code to handle the orientation change as you want and use your fork instead.