Thursday, November 3, 2011

Read some interesting data from your iDevice with iOS 4.3



Ever tried to read some interesting data like the Serial Number, IMEI, Phone Number… from your iPhone (or an other iDevice) ? Some data is easy to access, some other uses not supported API calls. I have written a simple App which can read the above mentioned data. You can download it here (click)

Reading common data is very easy, this is the Code for the UniqueIdentifier, iDevice Name, System Name, System Version and Model:
  1. // Stores the complete Text Output 
  2. NSMutableString *data = [[NSMutableString alloc] init];  
  3. // Reading Legal Apple Data 
  4. [data appendString:[NSString stringWithFormat: @"%@: %@nn",
    @"phoneUniqueIdentifier", [[UIDevice currentDevice] uniqueIdentifier]]]; 
  5. [data appendString:[NSString stringWithFormat: @"%@: %@nn",
    @"name", [[UIDevice currentDevice] name]]]; 
  6. [data appendString:[NSString stringWithFormat: @"%@: %@nn",
    @"systemName", [[UIDevice currentDevice] systemName]]]; 
  7. [data appendString:[NSString stringWithFormat: @"%@: %@nn",
    @"systemVersion", [[UIDevice currentDevice] systemVersion]]]; 
  8. [data appendString:[NSString stringWithFormat: @"%@: %@nn",
    @"model", [[UIDevice currentDevice] model]]]; 
  9. [data appendString:[NSString stringWithFormat: @"%@: %@nn",
    @"localizedModel", [[UIDevice currentDevice] localizedModel]]]; 
To access the IMEI and Serial Number you have to use the (semi)public IOKit framework. Erica Sadun has managed this and released the overwritten IOKit-Extension. I have included these files in my App and used it this way:
  1. #import "UIDevice-IOKitExtensions.h" 
  2.  
  3. // Reading not by the Appstore supported Data 
  4. [data appendString:[NSString stringWithFormat: @"%@: %@nn",
    @"IMEI", [[UIDevice currentDevice] imei]]]; 
  5. [data appendString:[NSString stringWithFormat: @"%@: %@nn",
    @"SerialNr", [[UIDevice currentDevice] serialnumber]]]; 

Be aware that you cannot submit an App with this IOKit-Extension into the Appstore!

No comments:

Post a Comment