Cordova Screen orientation lock not working iOS 16

After moving from iOS 15 to iOS 16 the cordova screen orientation lock api stopped working.


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:

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, *)) {
      [self.viewController setNeedsUpdateOfSupportedInterfaceOrientations];
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: