Detect notch and safearea using view.safeArea instead of hardcoding checking for screen height (device type).
$ npm install react-native-iphone-safe-area --save
$ react-native link react-native-iphone-safe-area
Libraries
➜ Add Files to [your project's name]
node_modules
➜ react-native-iphone-safe-area
and add RNIphoneSafeArea.xcodeproj
libRNIphoneSafeArea.a
to your project’s Build Phases
➜ Link Binary With Libraries
Cmd+R
)<android/app/src/main/java/[...]/MainActivity.java
import com.reactlibrary.RNIphoneSafeAreaPackage;
to the imports at the top of the filenew RNIphoneSafeAreaPackage()
to the list returned by the getPackages()
methodandroid/settings.gradle
:
include ':react-native-iphone-safe-area'
project(':react-native-iphone-safe-area').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-iphone-safe-area/android')
android/app/build.gradle
:
compile project(':react-native-iphone-safe-area')
RNIphoneSafeArea.sln
in node_modules/react-native-iphone-safe-area/windows/RNIphoneSafeArea.sln
folder to their solution, reference from their app.MainPage.cs
appusing Iphone.Safe.Area.RNIphoneSafeArea;
to the usings at the top of the filenew RNIphoneSafeAreaPackage()
to the List<IReactPackage>
returned by the Packages
method
import IphoneSafeArea from 'react-native-iphone-safe-area';
//...
const result = await IphoneSafeArea.hasNotch(); // true
const topNotch = await IphoneSafeArea.top(); // 44px