Use cordova org.apache.cordova.device-orientation plugin.