Skip to content

Commit

Permalink
crash on ios10 (#180)
Browse files Browse the repository at this point in the history
* crash on ios10

* crash on ios10
  • Loading branch information
Liqiankun committed Mar 7, 2021
1 parent 412ec2d commit 1d8a49f
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions ios/SafeAreaView/RNCSafeAreaProviderManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -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": @{
Expand All @@ -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),
},
}
} ;
}
}

Expand Down

0 comments on commit 1d8a49f

Please sign in to comment.