Reputation: 11
I'm trying to build an app that return the following information:
I saw that I could use CoreTelephony, but I came to doubt: To use these headers files (Import CoreTelephony.h from class-dump), the device must be jailbroken?
If not, the CoreTelephony its valid only for iOS6?
Thats how I do:
CTServerConnectionRef conn;
void ConnectionCallback(CTServerConnectionRef connection, CFStringRef string, CFDictionaryRef dictionary, void *data) {
NSLog(@"ConnectionCallback");
CFShow(dictionary);
}
- (NSString *)coreTelephonyInfoForKey:(const NSString *)key {
NSString *retVal = nil;
conn = _CTServerConnectionCreate(kCFAllocatorDefault, ConnectionCallback,NULL);
if (conn) {
struct CTResult result;
CFMutableDictionaryRef equipmentInfo = nil;
_CTServerConnectionCopyMobileEquipmentInfo(&result, conn, &equipmentInfo);
if (equipmentInfo) {
retVal = [NSString stringWithString:CFDictionaryGetValue(equipmentInfo, (__bridge const void *)(key))];
CFRelease(equipmentInfo);
}
CFRelease(conn);
}
return retVal;
}
- (NSString *)IMEI {
return [self coreTelephonyInfoForKey:@"kCTMobileEquipmentInfoIMEI"];
Here is my CoreTelephony.h
Upvotes: 1
Views: 5027
Reputation: 9570
It probably requires com.apple.coretelephony.Identity.get
entitlement. Found it in Preferences app.
Upvotes: 1
Reputation: 23298
Partly answering your question:
API which aren't documented called private API's (in iOS realm). I think you figured this out taking into account tag "iphone-privateapi
Private API's can be used both on jailbroken and non jailbroken phone. Generally speaking, the only technical difference between public and private API's is whether API is defined in .h files.
Sometimes private API's become oudated (modified, removed or protected by entitlements). The last one (protected by entitlements is most common case. An entitlement is permission which grants you ability to use some API's. On jailed devicesnly system applications can have entitlements. On jailbroken devices any app can have entitlements.
Getting back to your question. I didn't try CoreTelephony on iOS 7. Did you try it? ( I wasn't sure whether "If not, the CoreTelephony its valid only for iOS6?" implied that you tried it).
Upvotes: 1