iOS Caller ID Retrieve

亡梦爱人 提交于 2019-12-20 03:52:26

问题


I'm trying to get the caller number (for jailbroken devices) with this code: extern CFTypeRef CTCallCopyName(void*, CTCall* call);

NSLog(@"%@", CTCallCopyName(NULL, (CTCall*)call));

I receive the error: "CTCallCopyName(void*, CTCall*)", referenced from: ld: symbol(s) not found for architecture armv6

I have Core Telephony linked with my project. Maybe my prototype is wrong... i don't know. Any ideas? Xcode 3, sdk 4


回答1:


If you're calling this API in a .mm file, you have to declare it like extern "C" void foo(void); As far as I know, on iOS 5 ~ 7, you should use CTCallCopyAddress instead, the prototype is:

extern "C" CFStringRef CTCallCopyAddress(CFAllocatorRef, CTCallRef);

Notice that the second arg is a CTCallRef rather than a CTCall, which means you can't send it CTCall class methods (although some of them work). Besides linking CoreTelephony.framework, you can also load this symbol dynamically, as shown below:

static CFStringRef (*CTCallCopyAddress)(CFAllocatorRef, CTCallRef);

void Foo(CTCallRef call)
{
    void *libHandle = dlopen("/System/Library/Frameworks/CoreTelephony.framework/CoreTelephony", RTLD_LAZY);
    CTCallCopyAddress = (CFStringRef (*)(CFAllocatorRef, CTCallRef))dlsym(libHandle, "CTCallCopyAddress");
    NSString *address = (NSString *)CTCallCopyAddress(kCFAllocatorDefault, call);
    NSLog(@"The caller's address is %@", address);
    [address release];
    dlclose(libHandle);
}

BTW, I can't get CTCallCopyName to work in SpringBoard on iOS 5, haven't figured it out or tried on other systems yet. Hope this information helps!

EDIT: Just give it another try on iOS 5, CTCallGetID is the right function to get the caller ID in the addressbook, whose prototype is ABRecordID CTCallGetID(CTCallRef). iOS 6 and 7 are possibly the same.



来源:https://stackoverflow.com/questions/6365683/ios-caller-id-retrieve

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!