I tried exactly what is mentioned in react-native-safe-area-context I run the app in samsung android 9 and it was working as expected. But in my oppo device with android 8 insets were all 0. I'm using react native 0.61.
This is my root component.
import React from 'react';
import { StatusBar, Platform } from 'react-native';
import { Provider } from 'react-redux';
import { PersistGate } from 'redux-persist/es/integration/react';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import { store, persistor } from './common/StoreBuilder';
import Routes from './routes/index';
if (Platform.OS === 'android') StatusBar.setHidden(true);
const App = () => (
<Provider store={store}>
<PersistGate persistor={persistor}>
<SafeAreaProvider><Routes /></SafeAreaProvider>
</PersistGate>
</Provider>
);
export default App;
This is my consumer, which is immediate child of above component.
<SafeAreaConsumer>
{insets => {
return <View style={{
flex: 1,
paddingTop: insets.top,
paddingLeft: insets.left,
paddingBottom: insets.bottom,
paddingRight: insets.right,
}}>
<Router>
<Stack key="root" hideNavBar>
...
</Stack>
</Router>
<MessageContainer />
</View>
}}
</SafeAreaConsumer>