Repository navigation
fix: rotate the scanner to the forced scanOrientation in UIScene apps - #49
Open
andredestro wants to merge 2 commits into
Open
andredestro wants to merge 2 commits into
andredestro wants to merge 2 commits into
Conversation
andredestro
marked this pull request as ready for review
October 27, 2026 10:51
andredestro
requested review from
ItsChaceD,
OS-pedrogustavobilro,
OS-ruimoreiramendes,
alexgerardojacinto,
jcesarmobile,
markemer and
theproducer
and removed request for
a team
October 27, 2026 10:51
The fallback always picked the first orientation in the mask, so a forced landscape scanner opened with the interface in landscapeLeft was flipped 180 degrees to landscapeRight. Skip the rotation when the current orientation is already in the mask, and otherwise prefer how the device is held.
alexgerardojacinto
approved these changes
Nov 2, 2026
OS-ruimoreiramendes
approved these changes
Nov 2, 2026
markemer
reviewed
Nov 2, 2026
| /// The scene's current interface orientation, read from `effectiveGeometry` on iOS 16+ | ||
| /// (`interfaceOrientation` is deprecated as of iOS 26). | ||
| var currentInterfaceOrientation: UIInterfaceOrientation { | ||
| if #available(iOS 16.0, *) { return self.effectiveGeometry.interfaceOrientation } |
There was a problem hiding this comment.
Isn't iOS 16 the lowest we support these days?
Contributor
Author
There was a problem hiding this comment.
For Capacitor 9, yes. But this lib is also used by the Capacitor 8 barcode plugin and the Cordova plugin on MABS 12, which are both still on iOS 15, so I kept the pre-16 path.
alexgerardojacinto
approved these changes
Nov 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Makes a forced
scanOrientation(portrait or landscape) work in apps that use the UIScene lifecycle:requestGeometryUpdateon iOS 16+, theUIDeviceorientation fallback on iOS 15). On dismiss, it rotates to the device's current orientation if the app supports it, or back to the orientation in place before scanning.viewDidLayoutSubviews, after each transition completes (a 180° rotation changes no size, so no layout runs), and whenever the window scene'seffectiveGeometrychanges. That last one covers the forced rotation, where the first layout still sees the old orientation.effectiveGeometryon iOS 16+, sinceinterfaceOrientationis deprecated as of iOS 26.Context
With the UIScene lifecycle (mandatory when building with the iOS 27 SDK), presenting the scanner with a narrower
supportedInterfaceOrientationsno longer rotates the interface. WithscanOrientationset to landscape and the device held in portrait (or the other way around), the layout broke and no code was decoded.adaptivewas not affected.Tracked in RMET-5550. Related, same area: ionic-team/capacitor-barcode-scanner#58
Type of changes
Tests
adaptive: unchanged.Screenshots (if appropriate)
Checklist