Core Telephony 框架在 4.0 中部分公开

2023-10-23移动开发问题
8

本文介绍了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 中部分公开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

硬件音量按钮更改应用程序音量
Hardware Volume buttons change in app volume(硬件音量按钮更改应用程序音量)...
2024-08-12 移动开发问题
10

Cocos2d - 如何检查不同层中对象之间的交集
Cocos2d - How to check for Intersection between objects in different layers(Cocos2d - 如何检查不同层中对象之间的交集)...
2024-08-12 移动开发问题
8

突出显示朗读文本(在 iPhone 的故事书类型应用程序中)
Highlight Read-Along Text (in a storybook type app for iPhone)(突出显示朗读文本(在 iPhone 的故事书类型应用程序中))...
2024-08-12 移动开发问题
9

Cocos2D + 仅禁用 Retina iPad 图形
Cocos2D + Disabling only Retina iPad Graphics(Cocos2D + 仅禁用 Retina iPad 图形)...
2024-08-12 移动开发问题
10

如何将 32 位 PNG 转换为 RGB565?
How to convert 32 bit PNG to RGB565?(如何将 32 位 PNG 转换为 RGB565?)...
2024-08-12 移动开发问题
21

正确的 cocos2d 场景重启?
Proper cocos2d scene restart?(正确的 cocos2d 场景重启?)...
2024-08-12 移动开发问题
7