general question here. I'm using rn-device-info library. I want to know what will be the return on console.log("Device Model", DeviceInfo.getModel());
for iPhone X? Is it "iPhone X" or "iPhone 10"?
Thanks.
It will return iPhone X
.
Source: RNDeviceInfo.m
PS: Make sure you are on the latest version of rn-device-info
This is might be old question to answer but here is answer for people who looking for it, without installing any external libraries create file name isIphoneX.js
insert this code
import { Dimensions, Platform } from 'react-native';
export function isIphoneX() {
const dim = Dimensions.get('window');
return (
// This has to be iOS
Platform.OS === 'ios' &&
// Check either, iPhone X or XR
(isIPhoneXSize(dim) || isIPhoneXrSize(dim))
);
}
export function isIPhoneXSize(dim) {
return dim.height == 812 || dim.width == 812;
}
export function isIPhoneXrSize(dim) {
return dim.height == 896 || dim.width == 896;
}
the code above will check if it's iphone X, Xr you can update the code as you wish just create new functions and export them and use it inside you code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With