diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a5e941a..b4d1f041 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ ## XX.XX.XX +* Updated resolution extraction to accommodate iOS 26 deprecations. * Added a new function "addCustomNetworkRequestHeaders: customHeaderValues" for providing or overriding custom headers after init. * Updated user properties caching mechanism according to sessions. diff --git a/CountlyCommon.m b/CountlyCommon.m index bda72bfe..681f3759 100644 --- a/CountlyCommon.m +++ b/CountlyCommon.m @@ -341,6 +341,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) { @@ -349,14 +350,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];