iOS 来电显示检索

发布于 2024-11-16 01:14:04 字数 294 浏览 4 评论 0原文

我正在尝试使用以下代码获取来电号码(对于越狱设备): extern CFTypeRef CTCallCopyName(void*, CTCall* 调用);

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

我收到错误: “CTCallCopyName(void*, CTCall*)”,引用自: ld:未找到架构armv6的符号

我有与我的项目链接的Core Telephony。 也许我的原型是错误的......我不知道。有什么想法吗? Xcode 3、SDK 4

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

巴黎盛开的樱花 2024-11-23 01:14:04

如果您在 .mm 文件中调用此 API,则必须将其声明为 extern "C" void foo(void);据我所知,在 iOS 5 ~ 7 上,你应该使用 CTCallCopyAddress 代替,原型是:

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

注意第二个参数是 CTCallRef 而不是 CTCall,这意味着你不能向它发送 CTCall 类方法(尽管其中一些方法可以工作)。除了链接 CoreTelephony.framework 之外,您还可以动态加载此符号,如下所示:

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);
}

顺便说一句,我无法让 CTCallCopyName 在 iOS 5 上的 SpringBoard 中工作,还没有弄清楚或在其他系统上尝试过。希望这些信息有帮助!

编辑:在 iOS 5 上再试一次,CTCallGetID 是获取地址簿中来电显示的正确函数,其原型为 ABRecordID CTCallGetID(CTCallRef)。 iOS 6 和 7 可能是相同的。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文