From 1d8a49f97bd34ee31e5d1ba3635eb614c1620e80 Mon Sep 17 00:00:00 2001 From: David Date: Mon, 8 Mar 2021 03:46:42 +0800 Subject: [PATCH] crash on ios10 (#180) * crash on ios10 * crash on ios10 --- ios/SafeAreaView/RNCSafeAreaProviderManager.m | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/ios/SafeAreaView/RNCSafeAreaProviderManager.m b/ios/SafeAreaView/RNCSafeAreaProviderManager.m index 51c766b3..f145e5bb 100644 --- a/ios/SafeAreaView/RNCSafeAreaProviderManager.m +++ b/ios/SafeAreaView/RNCSafeAreaProviderManager.m @@ -20,8 +20,8 @@ - (UIView *)view - (NSDictionary *)constantsToExport { - if (@available(iOS 11.0, *)) { UIWindow* window = [[UIApplication sharedApplication] keyWindow]; + if (@available(iOS 11.0, *)) { UIEdgeInsets safeAreaInsets = window.safeAreaInsets; return @{ @"initialWindowMetrics": @{ @@ -40,7 +40,21 @@ - (NSDictionary *)constantsToExport } }; } else { - return @{ @"initialWindowMetrics": [NSNull null] }; + return @{ @"initialWindowMetrics": @{ + @"insets": @{ + @"top": @(20), + @"right": @(0), + @"bottom": @(0), + @"left": @(0), + }, + @"frame": @{ + @"x": @(window.frame.origin.x), + @"y": @(window.frame.origin.y), + @"width": @(window.frame.size.width), + @"height": @(window.frame.size.height), + }, + } + } ; } }