CallStateDisconnected only detected for incoming calls, not for calls made from my app

倖福魔咒の 提交于 2019-11-28 11:01:42

Here's the log from an iOS 5 phone:

2012-12-02 22:00:00.252 TestPhone[2297:707] didFinishLaunchingWithOptions:
2012-12-02 22:00:00.352 TestPhone[2297:707] applicationDidBecomeActive:
2012-12-02 22:00:06.708 TestPhone[2297:707] applicationWillResignActive:
2012-12-02 22:00:10.582 TestPhone[2297:1c03] Call start
2012-12-02 22:00:11.016 TestPhone[2297:707] applicationDidBecomeActive:
2012-12-02 22:00:12.536 TestPhone[2297:707] applicationWillResignActive:
2012-12-02 22:00:12.564 TestPhone[2297:707] applicationDidEnterBackground:
2012-12-02 22:00:36.543 TestPhone[2297:707] applicationWillEnterForeground:
2012-12-02 22:00:36.769 TestPhone[2297:707] applicationDidBecomeActive:
2012-12-02 22:00:36.840 TestPhone[2297:2e07] Call has been disconnected
2012-12-02 22:00:36.854 TestPhone[2297:707] applicationWillResignActive:
2012-12-02 22:00:49.885 TestPhone[2297:707] applicationDidBecomeActive:

and here's the log from an iOS 6 phone:

2012-12-03 06:27:55.401 TestPhone[7734:907] didFinishLaunchingWithOptions:
2012-12-03 06:27:55.462 TestPhone[7734:907] applicationDidBecomeActive:
2012-12-03 06:28:01.396 TestPhone[7734:907] applicationWillResignActive:
2012-12-03 06:28:04.345 TestPhone[7734:907] applicationDidBecomeActive:
2012-12-03 06:28:04.401 TestPhone[7734:1803] Call start
2012-12-03 06:28:05.824 TestPhone[7734:907] applicationWillResignActive:
2012-12-03 06:28:05.826 TestPhone[7734:907] applicationDidEnterBackground:
2012-12-03 06:28:17.318 TestPhone[7734:907] applicationWillEnterForeground:
2012-12-03 06:28:17.329 TestPhone[7734:907] applicationDidBecomeActive:

The "disconnected" message has just disappeared. (This isn't an answer, it's an observation.)

Here's the code I used. I I created a single-view application in xcode with a single button in the xib, and this is the whole of my UIViewController:

- (void)viewDidLoad {
    [super viewDidLoad];
    self.callCenter = [[CTCallCenter alloc] init];
    self.callCenter.callEventHandler = ^(CTCall* myCall) {
        NSString *call = myCall.callState;
        if ([call isEqualToString:CTCallStateDisconnected])
            NSLog(@"Call has been disconnected");
        else if([call isEqualToString:CTCallStateDialing]) 
            NSLog(@"Call start");
        else if ([call isEqualToString:CTCallStateConnected])
            NSLog(@"Call has just been connected");
        else if([call isEqualToString:CTCallStateIncoming])
            NSLog(@"Call is incoming");
        else
            NSLog(@"None");
    };
}

- (IBAction)callButtonPressed:(id)sender {
    NSString *number = @"tel:01234567890";
    UIWebView *callWebview = [[UIWebView alloc] init];
    callWebview.frame = self.view.frame;    
    [self.view addSubview:callWebview];
    NSURL *telURL = [NSURL URLWithString:number];
    [callWebview loadRequest:[NSURLRequest requestWithURL:telURL]];
}
@end
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!