Core Telephony framework partially public in 4.0

前端 未结 1 438
萌比男神i
萌比男神i 2020-12-20 03:47

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

1条回答
  •  清歌不尽
    2020-12-20 04:14

    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

    0 讨论(0)
提交回复
热议问题