问题描述
由于我不想越狱我的 iPhone,我正在开发一个需要访问 Core Telephony 框架的个人应用程序.
Since I don't want to jailbreak my iPhone i'm developing a personal application that needs to access the Core Telephony framework.
在 4.x Core Telephony 框架已部分公开,但其大部分未来仍处于隐藏状态并保持私有.
In 4.x Core Telephony framework has gone partially public but most of its futures are still hidden and kept private.
我已经下载了 seriot.ch 的头文件
I've joust downloaded the header files form seriot.ch
我找到了所有已知 CoreTelephony 函数的列表但我无法让我的代码做应该做的事情.有什么建议吗?
I've found a list of all the known CoreTelephony functions but i'm not able to make my code do what should be supposed to do. Some suggestion ?
在这些无用的情况下拒绝所有来电.
In these useless case refuse all incoming calls.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[window makeKeyAndVisible];
CTCallCenter *callCenter = [[CTCallCenter alloc] init];
callCenter.callEventHandler = ^(CTCall* call){
if (call.callState == CTCallStateIncoming) {
CTCallDisconnect(call);
}
};
return YES;
}
推荐答案
您不能将公共 CoreTelephony 呼叫事件处理程序与 CTCallDisconnect 等私有 CoreTelephony 函数一起使用.您可以在此处查看所需私有事件处理程序代码的工作示例:http://tech.ruimaninfo.com/?p=83 - 它们是关键位:
You can't use the public CoreTelephony call events handler with the private CoreTelephony functions like CTCallDisconnect. You can see a working example of the required private event handler code here: http://tech.ruimaninfo.com/?p=83 - they key bits:
// Register our event handler
id ct = CTTelephonyCenterGetDefault();
CTTelephonyCenterAddObserver(ct, NULL, callback, NULL, NULL, CFNotificationSuspensionBehaviorHold);
// Our callback
static void callback(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo)
{
NSString *notifyname=(NSString *)name;
if ([notifyname isEqualToString:@"kCTCallIdentificationChangeNotification"])
{
NSDictionary *info = (NSDictionary *)userInfo;
CTCall *call = (CTCall *)[info objectForKey:@"kCTCall"];
NSString *caller = CTCallCopyAddress(NULL, call);
NSLog(@"Incoming call: %@",caller);
CTCallDisconnect(call);
}
}
我已经确认这适用于 iOS5.1
I've confirmed this working on iOS5.1
这篇关于Core Telephony 框架在 4.0 中部分公开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!