Why am I seeing multiple iPhones returned instead of one device?
Nowadays, Apple releases a new generation of iPhones each year. But the distinction between devices blurs as the same hardware and software is used across generations.
Detecting between different iPhone models can be done but it requires a few methods.
The iPhone User-Agent
Most devices will have a User-Agent HTTP header. In an ideal world, you can identify details about the device from this User-Agent, including the browser, operating system, and hardware model.
Let’s look at an example User-Agent:
Mozilla/5.0 (Linux; Android 12; SM-F936B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36
To detect what phone model it is, we look for a model code. In this example, the presence of “SM-F936B” indicates a device name of Samsung Galaxy Z Fold4. You can find the model code information in the 51Degrees HardwareModel property.
Devices can also have more than one model code. Here are a few Samsung Galaxy Z Fold4 model codes that can appear in a User-Agent:
- SM-F936U
- SM-F936B
- SM-F936N
- SM-F936W
When the model codes are present in the User-Agent, we can resolve that detection to the model name.
Unfortunately, this same methodology does not apply to Apple devices. Apple are different in that they don’t include device model information in the User-Agent.
This is a User-Agent for an iPhone 15 running on iOS 17.0:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Safari/605.1.15
There is no mention of “iPhone 15” or any distinguishable hardware name in this User-Agent, so theoretically this could be any iPhone device. Therefore, we can’t rely solely on the User-Agent to detect and differentiate between Apple devices.
Detecting iPhones with JavaScript
Visually, some iPhones may look the same, but we can look for subtle variations in the hardware to help us differentiate between the device models.
For example, the iPhone 15 Pro Max and iPhone 15 Plus have the same screen display size and produce the same screen resolution, but they have different processing chips.
We can target these hardware variations – all we need is a little bit of code.
Using JavaScript, we can differentiate Apple devices by the way they render images. Thanks to the different specifications between devices, different hash codes are generated when images are rendered on a webpage. Here’s a blog discussing the JavaScript iPhone detection method further.
Unfortunately, this is not always a fail-safe option. With the overlap in Apple device's processors and rendering capabilities, it’s rare to resolve the detection to one singular device model.
Resolving to a group profile
For most devices, we can resolve the detection to a specific phone model that is found in the User-Agent. For iPhones where the model information is not included in the User-Agent, we resolve it to a generic group of device names. This is done through the 51Degrees HardwareName property.
Because some Apple devices may render the images the same way through the JavaScript method, a distinction cannot be made between models and a group of devices are returned instead. This is returned as a list from the HardwareName property.
You can see our Apple detection results table to see what group profile each Apple device falls into.
How to utilize the group profile detection
Since the method for detecting iPhone devices is unique, you may require a different solution if you wish to resolve the detection to a single device model.
One strategy we suggest is to take the HardwareName property result when it contains a group profile and separate them into individual device names. With this, you can then create a drop-down list on your website where the user can select their device.
For example, with an iPhone 15 your drop-down list could be based on the HardwareName property result (where the group profile results in iPhone 14 Pro, iPhone 15 Pro, or iPhone 15) or even the HardwareModelVariants property (using the iPhone 15, iPhone 14 Pro, and iPhone 15 pro Apple codes).
Rather than guessing the iPhone model or providing a false positive detection result, we’re clear what Apple detection results you can expect. If you have any questions about our Apple device detection, please do get in touch.