Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect the colour of an iPhone 5c? [duplicate]

After iPhone 5c announcement, i'm curious if anybody knows an API how to get an iPhone 5c colour? I'm sure everyone will find it convenient loading a corresponding UI colour scheme to the device colour.

I'm thinking about wrapping it in something like the UIDevice category, which will return a UIColor.

Update: @ColinE and @Ortwin Gentz has indicated the availability of private UIDevice instance method calls for it.

Please note, that in case of iPhone 5c, what you are really looking for is deviceEnclosureColor, as deviceColor will always return #3b3b3c, as it is a front colour.

method signature:

-(id)_deviceInfoForKey:(struct __CFString { }*)arg1 

UIDevice category for it:

@interface UIDevice (deviceColour)  - (id)_deviceInfoForKey:(struct __CFString { }*)arg1; - (NSString*)deviceColourString_UntilAppleMakesItPublic; - (NSString*)deviceEnclosureColour_UntilAppleMakesItPublic;   @end  @implementation UIDevice (deviceColour)  - (NSString*)deviceColourString_UntilAppleMakesItPublic {     return [self _deviceInfoForKey:@"DeviceColor"]; }  - (NSString*)deviceEnclosureColour_UntilAppleMakesItPublic {     return [self _deviceInfoForKey:@"DeviceEnclosureColor"]; }   @end 
like image 344
ambientlight Avatar asked Sep 12 '13 16:09

ambientlight


People also ask

Is the iPhone 5c plastic?

With an all-new design, this is iPhone as you've never seen it — or held it. iPhone 5c is beautifully, unapologetically plastic, the better to bring its five decidedly uncommon colours to life.

When did the iPhone 5c come out?

Apple launched the iPhone 5c in the US, Australia, Canada, China, France, Germany, Hong Kong, Japan, Puerto Rico, Singapore and the UK on September 20, 2013.


1 Answers

The device colour (used to?) be encoded in the serial number of the device. I don't have a device to test on with them not officially released yet, but I imagine the solution will be similar to this:

Typical format of the iPhone SN is as follows: AABCCDDDEEF

AA = Factory and Machine ID
B = Year of Manufacturing (9 is 2009/2019, 0 is 2010/2020, 1 is 2011 and so on)
CC = Production Week (01 is week 1 of B, 11 is week 11 of B and so on)
DDD = Unique Identifier
EE = Color (A4=black)
F = size (S=16GB, T=32GB)

[Source]

There is more information on old techniques here


I would like to point out however, that I expect there isn't a supported method of getting the serial number. Assuming you'd only like to know this information so that you can customise your UI, I'd just put in a user option or ask them to select the colour of their device on first startup (or some other early point in the app-user life)

like image 116
James Webster Avatar answered Sep 22 '22 20:09

James Webster