Getting iOS device "technical name"/"official model" #4353
Replies: 1 comment 1 reply
-
I found this post because I was looking for a way to get the proper full name of the iOS model, like Anyway, here is the patch file for modifying I pulled most of the code from this SO answer, no doubt as more iOS devices are added this answer will be updated. This is absolutely not exhaustively tested and may contain bugs anywhere and everywhere. I am an absolute novice with swift (as in I started this evening), so no guarantees of any kind with this patch. Cheers :) Patch file (unzip and place at |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi All, 👋
This topic was touched upon here and here but neither quite addressed my questions, so I'm posting a new discussion. 🙂
Background
We are attempting to migrate from the cordova-plugin-device plugin to the Capacitor Device plugin.
We use
cordova-plugin-device
for one thing, and that is to access three pieces of device information:In my limited testing so far on hybrid iOS and hybrid Android, it appears that Capacitor
Device
produces consistently detailed results for the OS version and Manufacturer which is awesome. However, at least on iOS, Model seems to have taken a step "backward" as far as information fidelity goes.cordova-plugin-device
provides a model value that looks something likeiPhone9,1
while CapacitorDevice
provides a value that looks something likeiPhone
. The value fromcordova-plugin-device
allows us to know what specific model of iPhone is actually being used (for example, an iPhone 6s, iPhone 12, etc.) while the CapacitorDevice
plugin does not. I'm referring to the more specific model value as the "technical name" or "official model" given that they've been cited as such in the linked issue/discussion mentioned at the beginning of this post.It appears that Capacitor
Device
usesUIDevice.model
which might not produce the more detailed model value given that Apple says,Possible examples of model strings are @”iPhone” and @”iPod touch”
.Looking at
cordova-plugin-device
, it appears to useUIDevice.modelVersion
. However, this is not a standard property from Apple's docs. I found the implementation of it here though.On Stack Overflow I found a question about implementing what appears to be virtually the same solution as
cordova-plugin-device
uses but in Swift. An answer to the question contains a Swift version of the implementation that may prove useful.Use Case
We really value having this more accurate/detailed model information because we collect analytics from our users and use the device model data to inform product and support decisions.
Questions
Is there a way to get this more detailed iOS model information from Capacitor
Device
?If that is not configurable, is it worth submitting as a feature request?
Workarounds
I was able to work around it by adding a custom Capacitor plugin that is local to our app and within it use the same native code as in the Stack Overflow answer which, again, is modeled off of the same solution as
cordova-plugin-device
uses:DeviceModelPlugin.swift
device-model.plugin.ts
(Ionic Angular TypeScript client code excerpt which invokes the plugin)
It might still be preferable if this was included out-of-the box. Again, if we think a feature request is appropriate or perhaps even a PR using the same solution as my workaround, please let me know.
Thanks so much for your help! 😀
Kevin
Beta Was this translation helpful? Give feedback.
All reactions