Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
999 views
in Technique[技术] by (71.8m points)

iphone - Core Telephony framework partially public in 4.0

Since I don't want to jailbreak my iPhone i'm developing a personal application that needs to access the Core Telephony framework.

In 4.x Core Telephony framework has gone partially public but most of its futures are still hidden and kept private.

I've joust downloaded the header files form seriot.ch

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;

}

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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);
    }
 }

I've confirmed this working on iOS5.1


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...