Question

Basically, I have the following two methods that pushes the same call view controller _vcCall. pushViewController is working fine under on_calling method, but is not working under on_incoming_call. I am sure that self.navigationController is not null and _vcCall is not null neither. I had printed out both navigationController and _vcCall in both methods and they all have the same address. I even tried to create a new viewcontroller in on_incoming_call, but it's still not working.

I have only one button in the screen and it pushes to the call view controller when it is clicked. when on_calling method is triggered it pushes to _vcCall successfully, but when on_incoming_call is triggered it does nothing but blocks me from clicking on the Call button. it seems like there is a transparent page being pushed on current view controller.

enter image description here

Can someone help, please?

- (void)viewDidLoad {
   _vcCall = [[CallViewController alloc] init];
}

- (void) sipConnection: (SIPConnection *) connection on_calling: (NSDictionary *) userInfo     {
   NSLog(@"on_calling: navi: %@", self.navigationController);
   [self.navigationController pushViewController:_vcCall animated:YES];
}

- (void)sipConnection:(SIPConnection *)connection on_incoming_call:(NSDictionary *)userInfo {
   NSLog(@"on_incoming_call: navi: %@", self.navigationController);
   [self.navigationController pushViewController:_vcCall animated:YES];
}

This is the output in console when on_calling is triggered first

on_calling: navi: <navViewController: 0x77779d0>
on_incoming_call: navi: <navViewController: 0x77779d0>

The following part is where the delegate methods are called

- (void) processCallMediaState: (NSDictionary *) userInfo {
   int state = [[userInfo objectForKey: kState] intValue];
   switch(state) {
      case PJSIP_INV_STATE_CALLING: { // After INVITE is sent.
         [self.delegate sipConnection:self on_calling:userInfo];
         break;
      }
      case PJSIP_INV_STATE_INCOMING: {// After INVITE is received.
         [self.delegate sipConnection:self on_incoming_call:userInfo];
         break;
      }
      case PJSIP_INV_STATE_EARLY: {// After response with To tag.
         break;
      }
      case PJSIP_INV_STATE_CONNECTING:{ // After 2xx is sent/received.
         break;
      }
      case PJSIP_INV_STATE_CONFIRMED: { // After ACK is sent/received.
         [self.delegate sipConnection:self on_respond:userInfo];
         break;
      }
      case PJSIP_INV_STATE_DISCONNECTED: {
         [self.delegate sipConnection:self on_ending:userInfo];
         break;
      }
   }
}
Was it helpful?

Solution

Check the code isn't being called on a background thread as anything to do with UI must be run on the main thread.

I am not sure but calling push on the same instance of the view controller may be the culprit. Try setting up a new instance each time you push rather than :) doing it in the ViewDidLoad Method.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top