Core Telephony framework partially public in 4.0(Core Telephony 框架在 4.0 中部分公开)
问题描述
由于我不想越狱我的 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 中部分公开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Core Telephony 框架在 4.0 中部分公开


基础教程推荐
- Android文本颜色不会改变颜色 2022-01-01
- 如何使用 YouTube API V3? 2022-01-01
- LocationClient 与 LocationManager 2022-01-01
- Android ViewPager:在 ViewPager 中更新屏幕外但缓存的片段 2022-01-01
- 在 iOS 上默认是 char 签名还是 unsigned? 2022-01-01
- “让"到底是怎么回事?关键字在 Swift 中的作用? 2022-01-01
- 如何使 UINavigationBar 背景透明? 2022-01-01
- :hover 状态不会在 iOS 上结束 2022-01-01
- 使用 Ryzen 处理器同时运行 WSL2 和 Android Studio 2022-01-01
- 固定小数的Android Money Input 2022-01-01