-
Notifications
You must be signed in to change notification settings - Fork 230
feat(ios): add support for ios 16 #107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Please Confirm this PR!! |
can u please release this change? |
What is holding up the release of this change? |
Hey, do you have any news about the merge of this PR? or something about the fix to screen orientation on IOS? |
Thanks @oofaish for sharing your fix! I've been testing on iOS 16.1 on a physical iPhone 13 Pro Max (Capacitor 4.4, Ionic 5, Angular 12, XCode 14.1, Ventura 13.0) and noticed two issues: 1 - Starting from primary portrait without my screen locked, calling From debugging, it seems L68 (UIInterfaceOrientationMaskLandscapeLeft) is getting called in the general landscape scenario, while L74 UIInterfaceOrientationMaskLandscapeRight is getting called on landscape-primary. 2 - Calling
It seems L93 is being called on iOS 16: XCode complains but still executes L96 ( This is minor stuff but wanted to share what I found while testing. Thanks again landscape-double-rotation.mov |
thanks @thmclellan I can have a look in the next couple of days |
@thmclellan the latest commit in the branch fixes the double rotation issue - the code is definitely a bit messy now - but seems to be working fine on the cases I have tried. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall it might be OK, except for the files that shouldnt be changed in the PR.
But as you suggested in a previous commit,
the code is definitely a bit messy now - but seems to be working fine
What if you split the code out into seperate methods?
-(void)handleAboveEqualIos16
{
NSObject *value;
if (orientationMask != 15) {
...
} else {
...
}
if (value != nil) {
_isLocked = true;
UIWindowScene *scene = (UIWindowScene*)[[UIApplication.sharedApplication connectedScenes] anyObject];
...
} else {
_isLocked = false;
}
}
-(void)handleBelowEqualIos15
{
NSValue *value;
if (orientationMask != 15) {
...
} else {
...
}
if (value != nil) {
_isLocked = true;
[[UIDevice currentDevice] setValue:value forKey:@"orientation"];
} else {
_isLocked = false;
}
}
And then in the screenOrientation
write
if ([UIDevice currentDevice] != nil){
if (@available(iOS 16.0, *)) {
[self handleAboveEqualIos16];
} else {
[self handleBelowEqualIos15];
}
}
It makes some of the code look repeative but it keeps most of the iOS 15 and below and 16 and above code seperated. Not all is split out but the main chunk of it.
Also you no longer need to have this value
and value16
name since its all split as well.. keep it simple as value
Thanks @oofaish for these changes. Tested on iOS 16 physical iPhone 13 Pro Max and the "landscape" lock is working as expected now. The "unlock" call still results in the below xcode warning but it's working fine from a user standpoint:
|
I get this error: |
iPhone XR / iOS 16.1.1 / XCode 14.1 Hi guys, I can confirm:
However, the unlocking doesn't happen anymore. I have no experience with Obj-C (please bear with me), but I tried to make it work this way:
and the _lastOrientation initialisation:
So, it kind of works, but the locked screen can be unlocked by pure rotation of the device. |
Any update about the merge of this PR or a fix for this screen orientation issue on IOS? |
Ooh thanks for the review @erisu. I can take a look. the changes that you say should not be there were due to another commit that was not in master it seems. Weird. I ll sort it out. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please Change
…y always calling setSupportedOrientations but only call setNeedsUpdateOfSupportedInterfaceOrientations at the end to avoid refreshing orientation twice
@erisu here is an updated PR:
confirmed locking/unlocking works on iOS15 and 16. |
Have a look at latest PR see what you think @erisu - appreciate all the comments. |
Hmm, looks like the tests failed again? 😡 |
should I be using
instead of
confirmed if I use |
Awesome, the update fixes the CI and everything is now green. The changes look great, clean, and readable to me. The only other small nitpick that I had was the variable name But, other than that, everything is great. |
thanks @erisu - changed the variable name too |
Can someone with write access merge this PR? 🤗 |
I will merge it in by tomorrow (JST). |
🙏 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not in a position to be able to physically test these changes as I don't have access to a mac, so I'll be relying on community members to make that distinction...
But codewise everything appears okay.
Will this fix be getting published via NPM? The latest version there is 3.0.2 - cordova-plugin-screen-orientation. |
@erisu do I need to create a new tag? can we do this manually or should I be putting up another PR? |
It will be, but we cannot provide an ETA.
Nope, the tags are all managed by the release processed. |
@oofaish - I tested this solution on iPhone 13 Pro Max v16.1.1. But the fix is not working. I am getting black(BLANK) screen when device is rotated to Landscape mode. What could be the issue? Can you please help |
@shruti-talekar please open a new issue and describe the problem, how you compiled the code, any error messages, etc - my tests have been working fine I am afraid. |
Platforms affected
Apple devices running iOS 16
Motivation and Context
resolves #100
Currently orientation is broken on iOS 16 with
Setting UIDevice.orientation is not supported. Please use UIWindowScene.requestGeometryUpdate(_:)
Description
deprecate on whether iOS 16 is available - either use the old method or the new one.
Testing
confirmed on iPhone 11 running iOS 15 and iPhone 13 Pro running iOS 16.
I have not confirmed all features work, but simply setting orientations works - the old pre iOS 16 should be unaffected.
Checklist
(platform)
if this change only applies to one platform (e.g.(android)
)