iOS来电显示检索 [英] iOS Caller ID Retrieve

查看:241
本文介绍了iOS来电显示检索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用下面的代码获取调用者号码(用于越狱设备):
extern CFTypeRef CTCallCopyName(void *,CTCall * call);

< (CTCallCopyName(NULL,(CTCall *)call));

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



我的Core Telephony与我的项目链接。
也许我的原型是错的......我不知道。有任何想法吗?
Xcode 3,sdk 4

解决方案

如果您在.mm文件中调用此API,则必须声明它像extern C void foo(void);据我所知,在iOS 5〜7上,应该使用CTCallCopyAddress,原型是:

  externC CFStringRef CTCallCopyAddress(CFAllocatorRef,CTCallRef); 

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

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

void Foo(CTCallRef调用)
{
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(@调用者的地址是%@,地址);
[地址发布];
dlclose(libHandle);
}

顺便说一下,我无法让CTCallCopyName在iOS 5的SpringBoard上工作,还没有弄清楚或试用过其他系统。希望这些信息对您有所帮助!编辑:在iOS 5上再次尝试一下,CTCallGetID是在地址簿中获取调用者ID的正确函数,其原型是ABRecordID CTCallGetID (CTCallRef)。 iOS 6和7可能是相同的。


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

解决方案

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.

这篇关于iOS来电显示检索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆