After moving from iOS 15 to iOS 16 the cordova screen orientation lock api stopped working.
Plugin: https://github.com/apache/cordova-plugin-screen-orientation
The reason for this issue is that the following line on that plugin no longer works in iOS 16
[[UIDevice currentDevice] setValue:value forKey:@"orientation"];
This has been reported here also: https://developer.apple.com/forums/thread/707735
The temporary fix (until Cordova team fixes this issue) will be to go to your Pods of iOS project:
and modify the CDVOrientation file, replace the following line:
[[UIDevice currentDevice] setValue:value forKey:@"orientation"]
with this:
if (@available(iOS 16.0, *)) {
#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_15_5
[self.viewController setNeedsUpdateOfSupportedInterfaceOrientations];
#endif
}
else {
[[UIDevice currentDevice] setValue:value forKey:@"orientation"];
}
Further Reference: setNeedsUpdateOfSupportedInterfaceOrientations
Run the project againts your device or simulator, this time the orientation lock will work with iOS 16.
Issue has been reported here also: https://github.com/apache/cordova-plugin-screen-orientation/issues/100