Ad

How To Determine The Apple Watch Model?

- 1 answer

The WKInterfaceDevice.current().model property does not give a model number:

For Apple Watch, the value of this string is Apple Watch.

How can the exact Apple Watch model be determined from iOS?

Watch app screenshot, image credits https://support.apple.com/en-us/HT204507

Ad

Answer

There is no public API to get that exact information.

You can however use the following (I'll let you translate into Swift):

- (NSString*) modelIdentifier {
    size_t size = 0;
    sysctlbyname("hw.machine", NULL, &size, NULL, 0);
    char* machine = malloc(size);
    sysctlbyname("hw.machine", machine, &size, NULL, 0);
    NSString* model = [NSString stringWithCString: machine encoding: NSUTF8StringEncoding];
    free(machine);
    return model;
}

This returns a string in the format: "Watch1,1". You'll need to provide a lookup table to do ID -> Name translation.

"Watch1,1" -> Apple Watch 38mm
"Watch1,2" -> Apple Watch 42mm
"Watch2,3" -> Apple Watch Series 2 38mm
"Watch2,4" -> Apple Watch Series 2 42mm
"Watch2,6" -> Apple Watch Series 1 38mm
"Watch2,7" -> Apple Watch Series 1 42mm
"Watch3,1" -> Apple Watch Series 3 38mm Cellular
"Watch3,2" -> Apple Watch Series 3 42mm Cellular
"Watch3,3" -> Apple Watch Series 3 38mm
"Watch3,4" -> Apple Watch Series 3 42mm

By the way, this sysctlbyname API also works for iOS.

Cheers.

Ad
source: stackoverflow.com
Ad