核心电话框架在4.0中部分公开 [英] Core Telephony framework partially public in 4.0

查看:56
本文介绍了核心电话框架在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核心电话框架已经部分公开,但其大部分期货仍然隐藏并保密。

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

这篇关于核心电话框架在4.0中部分公开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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