1

ONLY for iOS version 15.3.1 & 16.2, we are getting device identifiers instead of device name on screen. For Eg. 1. if im using iPhone 13, then I am getting iPhone 14,5 as a device name

  1. If I am us gin iPhone 11, then I'm getting iPhone 12,1 as a device name. I want right device name, not its identifiers. What can be the solution. It is happening only for iOS versions 15.3.1 & 16.2.
 + (NSString *)getName:(char *)typeSpecifier
    {
      size_t size;
        sysctlbyname(typeSpecifier, NULL, &size, NULL, 0);
        char *machinedetails = malloc(size);
      sysctlbyname(typeSpecifier, answer, &size, NULL, 0);
      NSString *results = [NSString stringWithCString:answer encoding: NSUTF8StringEncoding];
      free(answer);
      return results;
    }
    
    + (NSString *)platform
    {
      return [self getName:"hw.machine"];
    }

Thanks

please provide a solution.

SonalB
  • 13
  • 4
  • How are you accessing the device name? – Paulw11 Feb 20 '23 at 07:25
  • after writing above code, we are calling platform() method and checking for platforms. if platform Is iPhone 1,1, then return iPhone 2G as a device name and so on. @Paulw11 sir – SonalB Feb 20 '23 at 07:51
  • Does this answer your question? [Determine device (iPhone, iPod Touch) with iOS](https://stackoverflow.com/questions/448162/determine-device-iphone-ipod-touch-with-ios) or [How to determine the current iPhone/device model?](https://stackoverflow.com/questions/26028918/how-to-determine-the-current-iphone-device-model) – HangarRash Feb 20 '23 at 08:10
  • no @HangarRash sir. I tried using [[UIDevice currentDevice] name] instead of above code, but it didn't work. its only giving problem for iOS 15.3.1 & 16.2 – SonalB Feb 20 '23 at 08:15
  • I'm not suggesting the use of `[[UIDevice currentDevice] name]`. The questions and answers I linked mostly make use of `sysctlbyname` and `hw.machine` to get the device code which then needs to be converted to a device type by hardcoding the list. It has always been this way. – HangarRash Feb 20 '23 at 08:20

0 Answers0