DeviceInfo.getModel() return `iPhone`, not expected `iPhone XR`
See original GitHub issueBug
my iPhone XR’s model
is A2107 , does not in the dictionary below
https://github.com/react-native-community/react-native-device-info/blob/master/ios/RNDeviceInfo/RNDeviceInfo.m#L145
that cause DeviceInfo.getModel()
return iPhone
, not expected iPhone XR
,
and then DeviceInfo.hasNotch()
return false
, because brand
and model
dose not match devicesWithNotch:
{
brand: 'Apple',
model: 'iPhone XR',
},
and in iPhone 11
simulator , model is A2111
, the same reason lead DeviceInfo.getModel()
return iPhone
, not expected iPhone 11
, then DeviceInfo.hasNotch()
return false
Environment info
React native info output:
System:
OS: macOS 10.14.6
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Memory: 1.37 GB / 16.00 GB
Shell: 5.3 - /bin/zsh
Binaries:
Node: 12.3.1 - /usr/local/bin/node
Yarn: 1.16.0 - /usr/local/bin/yarn
npm: 6.11.3 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.1, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0
Android SDK:
API Levels: 21, 23, 26, 27, 28
Build Tools: 23.0.1, 26.0.1, 28.0.3, 29.0.2
IDEs:
Android Studio: 3.5 AI-191.8026.42.35.5900203
Xcode: 11.1/11A1027 - /usr/bin/xcodebuild
npmPackages:
react: 16.9.0 => 16.9.0
react-native: 0.61.2 => 0.61.2
// paste it here
Library version: ^4.0.1-beta.5
Steps To Reproduce
…
Describe what you expected to happen:
- in my
iPhone XR
,getModel()
returniPhone XR
, notiPhone
,hasNotch()
returntrue
- in
iPhone 11
,getModel()
returniPhone 11
, notiPhone
,hasNotch()
returntrue
Reproducible sample code
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (1 by maintainers)
Top Results From Across the Web
How to determine the current iPhone/device model?
I know there is a property named UIDevice.currentDevice().model but it only returns device type (iPod touch, iPhone, iPad, iPhone Simulator, etc). I also...
Read more >Return iPhone settings to their defaults - Apple Support (KW)
On iPhone, return settings to their defaults without erasing your content. ... Go to Settings > General > Transfer or Reset iPhone >...
Read more >Get information about your iPhone - Apple Support
On iPhone, find storage information, battery usage, iOS version number, model number, serial number, warranty information, and more.
Read more >iPhone parts and service history - Apple Support
For iPhone XR, XS, XS Max, and later, including iPhone SE (2nd generation), you can check if the battery has been replaced.
Read more >Apple Trade In - Education
Trade in your iPhone, iPad, Mac, Watch, or any other device for credit toward a new one, ... Return it to us using...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Indeed - that logic had an issue, great find. I just fixed it - it will be in the v4 release
For some reason, it still doesn’t work for iPhone 12, and iPhone SE. I tried looking into library code, it is taking into account the model, converts it to a name, and then checks with a list of notched devices. I ended up copying those lists into my project (device name, notched devices), and there with the code, I have everything works as expected. I’m looking at the code and can’t seem to find where the problem lies. (it is latest version, installed pods, I checked everything I could think off)