ScreenOrientation issue


#1

Hi, I have a problem with ScreenOrientation when update my app to ionic3.
I used this code -> this.screenOrientation.lock(‘portrait’);
And got the error ->
ERROR Error: Uncaught (in promise): NotSupportedError: lockOrientation() is not available on this device.
at new Error (native)
at Error.g (file:///android_asset/www/build/polyfills.js:3:7133)
at l (file:///android_asset/www/build/polyfills.js:3:6251)
at file:///android_asset/www/build/polyfills.js:3:5607
at t.invoke (file:///android_asset/www/build/polyfills.js:3:14529)
at Object.inner.inner.fork.onInvoke (file:///android_asset/www/build/main.js:4424:37)
at t.invoke (file:///android_asset/www/build/polyfills.js:3:14469)
at n.run (file:///android_asset/www/build/polyfills.js:3:9741)
at file:///android_asset/www/build/polyfills.js:3:6774
at t.invokeTask (file:///android_asset/www/build/polyfills.js:3:15213)
at Object.inner.inner.fork.onInvokeTask (file:///android_asset/www/build/main.js:4415:37)
at t.invokeTask (file:///android_asset/www/build/polyfills.js:3:15134)
at n.runTask (file:///android_asset/www/build/polyfills.js:3:10390)
at a (file:///android_asset/www/build/polyfills.js:3:5313)defaultErrorLogger @ main.js:1364

Any hint please ?


#2

Hi, I have removed the old version and add new version 2.0.0 to my project and it works.


#3

Hi, @thanhdoan1812

Install this module

ionic plugin rm cordova-plugin-screen-orientation --save
ionic plugin add cordova-plugin-screen-orientation@1.4.3 --save

ionic platform rm android --save
ionic platform add android --save

Who knows how to update the link which ionic plugin add is using? Is it fetched from npm? Do we have to contact the author of the old repository or how does this work?


#4

Hi, thank you for your reply, but the version 1.4.3 not work on ionic3, I have to update to version 2.0.0.
About the “update the link which ionic plugin add is using”, you mean that you want to update version of all ionic plugin ?


#5

Hi, @thanhdoan1812

Thanks,You should install latest plug-in using

ionic plugin add cordova-plugin-screen-orientation@latest

thanks


#6

did it work?
whats the solution?
I am getting
vendor.js:1703 ERROR Error: Uncaught (in promise): NotSupportedError: screen.orientation.lock() is not available on this device.
at c (polyfills.js:3)

version 4.4.2