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

后端 未结 1 1232
野性不改
野性不改 2020-12-10 13:31

I can\'t detect end of call (state CallStateDisconnected), if I make call from my app. But if I receive call when my app is active, I can detect that state. I also receive s

相关标签:
1条回答
  • 2020-12-10 13:38

    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
    
    0 讨论(0)
提交回复
热议问题