The model of iPhone is essential for analytics and optimization. 51Degrees handles the complexities.
51Degrees provides four different methods to identify the price, release age, screen, chipset, codecs, and other information for an iPhone. This article explains the different methods and what you can expect from each.
Type Allocation Codes (TAC)
Every GSMA cellular device comes with an eight digit TAC code. These digits are the first eight of the device serial number, often referred to as an International Mobile Equipment Identity or IMEI.
Here’s an example IMEI from an iPhone 17 Pro Max.
353837417378351
The TAC code is the first eight digits highlighted in yellow. When used with 51Degrees TAC lookup all the details associated with the iPhone 17 Pro Max are returned.
No information about the operating system or apps are returned because the TAC code does not relate to these components.
TAC code is the best evidence to use when you have access to the mobile network or low-level device information. TAC is the perfect device model key for our telecoms and insurance customers.
Native Key
Gaining user's permissions to retrieve the IMEI number on iOS can be complex for non telecoms operators. 51Degrees’ app developers therefore prefer to use the details returned from the iOS operating system calls.
The following Swift code can be used to retrieve the required value.
func getHardwareMachine() -> String {
var size: Int = 0
// First, determine the size of the data
sysctlbyname("hw.machine", nil, &size, nil, 0)
// Allocate buffer
var machine = CChar
// Retrieve the value
sysctlbyname("hw.machine", &machine, &size, nil, 0)
// Convert to Swift String
return String(cString: machine)
}
When executed on an iPhone 17 Pro Max the value returned will be “iPhone18,2”.
The returned value along with iOS can then be used to lookup all the information about the model.
To explore further, check out the NativeModel and NativePlatform properties.
The native key for iOS – and its twin for Android – are the go to keys for app developers who don’t want to create fake User-Agents for their own analysis.
Web
When operating within a web environment two methods are available depending on the application and browser being used.
Web View
Many app vendors modify the User-Agent provided by Safari’s WebKit and add additional information that includes the model of the device. This is typically the same value returned from the native key approach described previously.
Consider the following User-Agent returned from Safari.
Mozilla/5.0 (iPhone; CPU iPhone OS 18_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/23A355
There is no information to indicate the model of iPhone that generated it. 51Degrees returns all the possible iPhone models that might relate to iOS under these conditions.
However, apps like those from Meta append additional information which does include the model value to the stock User-Agent. See the section highlighted in yellow from the following example.
Mozilla/5.0 (iPhone; CPU iPhone OS 18_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/23A355 Instagram 405.1.0.27.75 (iPhone18,2; iOS 26_0_1; en_US; en; scale=3.00; 1320x2868; IABMV/1; 817093285)
When used with 51Degrees the additional information now includes the precise model information in addition to other components.
See the result here.
Appending information to the stock User-Agent is the preferred method of iPhone model identification for app vendors who wish to make the model and other useful information available to their partners.
JavaScript
When working within the Safari browser outside of a native iOS app no such User-Agent amendments are available. HTTP headers alone are not going to get the model information.
This is where 51Degrees’ client side evidence comes into play. When 51Degrees identifies the presence of an iOS device, JavaScript can be sent in response, that when executed provides additional information.
See the result of the output from JavaScript iPhone model detection here.
The JavaScript progressively tests the device to collect more information. Examples of additional data points include screen size, graphics chipset, color gamat, and the hash of complex rendered 3D geometries.
These details are then provided in a subsequent request to the device detection library to return the precise iPhone model or if still not possible a narrow grouping.
This technique is made possible via the iPhone testing carried out by the 51Degrees Data Team every time a new device or version is released. We consider zoom mode as well as standard mode to ensure those people with visual impairments are not discriminated against.
51Degrees regularly publishes the table of iPhone model groupings. Check out the latest table here.
Using JavaScript for device detection works well in all situations, although sometimes results in groups of models.
What Next?
We continue to make the case for Apple to include device model information within the User-Agent. Restricting this information from the web whilst enabling it for apps and their own internal uses is anticompetitive.
If you’d like to join the campaign to restore and guarantee interoperability on the Open Web then contact Movement for an Open Web, a not-for-profit we support.
Conclusion
Whatever your requirements, 51Degrees has an option for Apple. Have a play and read the documentation. If you'd like a bespoke On-premise license then contact us.
