question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DeviceInfo.getModel() return `iPhone`, not expected `iPhone XR`

See original GitHub issue

Bug

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 image

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:

  1. in my iPhone XR,getModel() return iPhone XR, not iPhone, hasNotch() return true
  2. in iPhone 11, getModel() return iPhone 11, not iPhone, hasNotch() return true

Reproducible sample code

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
mikehardycommented, Oct 11, 2019

Indeed - that logic had an issue, great find. I just fixed it - it will be in the v4 release

0reactions
abarisic86commented, Aug 11, 2022

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)

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found