From 96528b59161ee465a76d20f7f390fdad6cf4be26 Mon Sep 17 00:00:00 2001 From: Arif Burak Demiray Date: Wed, 1 Oct 2025 17:31:44 +0300 Subject: [PATCH 1/2] refactor: screen size functions to acmm ios 26 --- CHANGELOG.md | 3 +++ CountlyCommon.m | 4 +++- CountlyDeviceInfo.m | 27 +++++++++++++++++++++++---- CountlyFeedbacksInternal.m | 3 ++- 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index acd3e599..598a44a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## XX.XX.XX +* Updated resolution extraction to accommodate iOS 26 deprecations in UIScreen/UIScene APIs. + ## 25.4.6 * Added the ability to record reserved events. * Changed default log level from "CLYInternalLogLevelDebug" to "CLYInternalLogLevelVerbose". diff --git a/CountlyCommon.m b/CountlyCommon.m index 485268cd..5c151a06 100644 --- a/CountlyCommon.m +++ b/CountlyCommon.m @@ -338,6 +338,7 @@ - (NSURLSession *)URLSession - (CGSize)getWindowSize { #if (TARGET_OS_IOS) UIWindow *window = nil; + CGFloat screenScale; if (@available(iOS 13.0, *)) { for (UIScene *scene in [UIApplication sharedApplication].connectedScenes) { @@ -346,14 +347,15 @@ - (CGSize)getWindowSize { break; } } + screenScale = window.traitCollection.displayScale; } else { window = [[UIApplication sharedApplication].delegate window]; + screenScale = [UIScreen mainScreen].scale; } if (!window) return CGSizeZero; UIEdgeInsets safeArea = UIEdgeInsetsZero; - CGFloat screenScale = [UIScreen mainScreen].scale; if (@available(iOS 11.0, *)) { safeArea = window.safeAreaInsets; safeArea.left /= screenScale; diff --git a/CountlyDeviceInfo.m b/CountlyDeviceInfo.m index 7af25929..6ebc99f5 100644 --- a/CountlyDeviceInfo.m +++ b/CountlyDeviceInfo.m @@ -261,11 +261,29 @@ + (NSString *)carrier + (NSString *)resolution { - CGRect bounds; - CGFloat scale; + CGRect bounds = CGRectZero; + CGFloat scale = 0; #if (TARGET_OS_IOS || TARGET_OS_TV) - bounds = UIScreen.mainScreen.bounds; - scale = UIScreen.mainScreen.scale; + UIWindow *window = nil; +#if (TARGET_OS_IOS) + if (@available(iOS 13.0, *)) { +#elif (TARGET_OS_TV) + if (@available(tvOS 13.0, *)) { +#endif + for (UIScene *scene in [UIApplication sharedApplication].connectedScenes) { + if ([scene isKindOfClass:[UIWindowScene class]]) { + window = ((UIWindowScene *)scene).windows.firstObject; + break; + } + } + if(window){ + bounds = window.bounds; + scale = window.traitCollection.displayScale; + } + } else { + bounds = UIScreen.mainScreen.bounds; + scale = UIScreen.mainScreen.scale; + } #elif (TARGET_OS_WATCH) bounds = WKInterfaceDevice.currentDevice.screenBounds; scale = WKInterfaceDevice.currentDevice.screenScale; @@ -519,3 +537,4 @@ - (void)resetInstance } @end + diff --git a/CountlyFeedbacksInternal.m b/CountlyFeedbacksInternal.m index 71a9e46a..1f5e80bf 100644 --- a/CountlyFeedbacksInternal.m +++ b/CountlyFeedbacksInternal.m @@ -300,7 +300,8 @@ - (void)presentRatingWidgetInternal:(NSString *)widgetID closeButtonText:(NSStri { __block CLYInternalViewController* webVC = CLYInternalViewController.new; webVC.view.backgroundColor = UIColor.whiteColor; - webVC.view.bounds = UIScreen.mainScreen.bounds; + CGSize windowSize = [CountlyCommon.sharedInstance getWindowSize]; + webVC.view.bounds = CGRectMake(0, 0, windowSize.width, windowSize.height); webVC.modalPresentationStyle = UIModalPresentationCustom; WKWebView* webView = [WKWebView.alloc initWithFrame:webVC.view.bounds]; From 5ec8e6c4cdc9eeead6a41ad41aa819c932f2c4b2 Mon Sep 17 00:00:00 2001 From: Arif Burak Demiray <57103426+arifBurakDemiray@users.noreply.github.com> Date: Thu, 2 Oct 2025 10:13:23 +0300 Subject: [PATCH 2/2] Simplify changelog entry for iOS 26 updates --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 598a44a6..2be25f0b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ ## XX.XX.XX -* Updated resolution extraction to accommodate iOS 26 deprecations in UIScreen/UIScene APIs. +* Updated resolution extraction to accommodate iOS 26 deprecations. ## 25.4.6 * Added the ability to record reserved events.