Skip to content
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

Stop using UIScreen.mainScreen to fix accent color #54

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions PostHog/Internal/PHGPostHogIntegration.m
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,13 @@ - (NSDictionary *)staticContext
dict[@"$os_name"] = device.systemName;
dict[@"$os_version"] = device.systemVersion;

CGSize screenSize = [UIScreen mainScreen].bounds.size;
dict[@"$screen_width"] = @(screenSize.width);
dict[@"$screen_height"] = @(screenSize.height);
// Access the screen via a window as UIScreen.mainScreen is deprecated
// and using it messes with the accent color in SwiftUI apps.
UIScreen *appScreen = UIApplication.sharedApplication.windows.firstObject.screen;
if (appScreen != nil) {
dict[@"$screen_width"] = @(appScreen.bounds.size.height);
dict[@"$screen_height"] = @(appScreen.bounds.size.width);
}

return dict;
}
Expand Down