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.

Return raw DeviceId value for iOS (at least)

See original GitHub issue

Description

Current Implementation for DeviceInfo.getModel()

NSString* deviceName = [deviceNamesByCode objectForKey:self.deviceId];

    if (!deviceName) {
        // Not found on database. At least guess main device type from string contents:

        if ([self.deviceId rangeOfString:@"iPod"].location != NSNotFound) {
            deviceName = @"iPod Touch";
        }
        else if([self.deviceId rangeOfString:@"iPad"].location != NSNotFound) {
            deviceName = @"iPad";
        }
        else if([self.deviceId rangeOfString:@"iPhone"].location != NSNotFound){
            deviceName = @"iPhone";
        }
        else if([self.deviceId rangeOfString:@"AppleTV"].location != NSNotFound){
            deviceName = @"Apple TV";
        }
    }
    return deviceName;

Suggested Implementation:

 NSString* deviceName = [deviceNamesByCode objectForKey:self.deviceId];
  
  if (!deviceName) {
    // Not found in the list
    deviceName = self.deviceId;
  }
  
  return deviceName;

Use Case

When ever Apple releases new devices we have wait till this library is updated to get device model, currently we get only iPhone or iPad for new versions.

Better to return deviceId as default for new devices, which will be useful in analytics…

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
rangavcommented, Apr 3, 2019

Yeah getDeviceId additional function is also good option for both platform.

0reactions
mikehardycommented, Apr 3, 2019

FYI - here’s how I’m going to maintain the getModel/getDevice APIs for iOS going forward https://github.com/react-native-community/react-native-device-info/pull/618#issuecomment-479661030

Read more comments on GitHub >

github_iconTop Results From Across the Web

UIDevice uniqueIdentifier deprecated - What to do now?
For apps still using uniqueIdentifier, iOS7 now returns FFFFFFFF + identifierForVendor which is breaking a lot of badly written non-renewing subscription apps.
Read more >
Mobile Device Management Protocol Reference
The Mobile Device Management (MDM) protocol provides a way for system administrators to send device management commands to managed iOS ...
Read more >
Default Properties Collected by Mixpanel
Mp Api Endpoint (raw property name: $mp_api_endpoint) This is the value of the Host Header based on the request to our ingestion service....
Read more >
Track unique users in Amplitude
This section explains in detail how Amplitude generates an Amplitude ID in different scenarios. Use advertising identifiers as the device ID.
Read more >
Global device ID validation | Adobe Audience Manager
Following is an example of an error returned because the ID is sent in as an Apple IDFA, which should only contain upper...
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