8

I have a problem (but not really) with callkit.

I implemented callkit in my app and it works great. I can get a second call to my app and callkit offeres me options to End&Accept, Decline or Hold&Accept. Same goes if I am in a cellular (gsm) call and I get a call on my app. But when I am in app call (on callkit) and get a cellular(gsm) call I only get 2 options: Decline or End&Accept.

Any idea why? Or how I can get all 3 options?

static var providerConfiguration: CXProviderConfiguration {

    var providerConfiguration: CXProviderConfiguration
    providerConfiguration = CXProviderConfiguration(localizedName: "app name")

    providerConfiguration.supportsVideo = false
    providerConfiguration.maximumCallsPerCallGroup = 1
    providerConfiguration.maximumCallGroups = 3
    providerConfiguration.supportedHandleTypes = [.phoneNumber]
    return providerConfiguration
}

I have implemented:

providerDidReset, 
CXStartCallAction, 
CXAnswerCallAction, 
CXEndCallAction, 
CXSetHeldCallAction, 
CXSetMutedCallAction, 
timedOutPerforming action, 
didActivate audioSession, 
didDeactivate audioSession.

In my app delegate I have function that checks useractivity. I put breakpoints in all of the functions but nothing gets called before the view for incoming cellular (gsm) call is shown.

I googled but couldn't find the solution. As far as I can see, callkit is working perfectly.

AndrejH
  • 2,028
  • 1
  • 11
  • 23
Redssie
  • 181
  • 1
  • 12

2 Answers2

1

I struggled with this for outgoing calls. For outgoing calls, make sure you call this method for the call once it is answered by the remote side:

[self.provider reportOutgoingCallWithUUID:currentCall.uuid connectedAtDate:[NSDate date]];

If you do not, the call is stuck "connecting" from CallKit's perspective and I have found that the native incoming call UI for other calls will not provide the "send to voicemail" and "hold and accept" options for incoming calls while another call is "connecting".

I struggled with this for a bit today until I figured that part out. I also am calling:

 [self.provider reportOutgoingCallWithUUID:currentCall.uuid startedConnectingAtDate:[NSDate date]];

from within:

- (void)provider:(CXProvider *)provider performStartCallAction:(CXStartCallAction *)action

Not sure if that part is necessary but I'm doing it because that's what the Speakerbox demo does. Kind of, they do it in a callback... I just do it immediately.

Hiren
  • 12,720
  • 7
  • 52
  • 72
Chad Barbe
  • 21
  • 1
  • Thank you for taking time to help. However i do set that already and holding is working if all calls are voip. if one is native (gsm) and another voip then holding does not work. – Redssie Sep 10 '18 at 05:46
  • One more suggestion... try implementing CXCallObserverDelegate and setting yourself as the call observer delegate: [_callController.callObserver setDelegate:self queue:nil]; Then print out everything about each call on every update. Like this: AWLogInfo(@"%@: callChanged uuid=%@ hasEnded=%d, hasConnected=%d isOnHold=%d, isOutgoing=%d", [self class], call.UUID, call.hasEnded, call.hasConnected, call.isOnHold, call.isOutgoing); With that information, I was able to see that my calls were not actually "connected". See if that is your case. – Chad Barbe Sep 11 '18 at 19:19
  • obviously use your own logging method, not AWLogInfo. That's my own method. – Chad Barbe Sep 11 '18 at 19:21
  • Thank you for the idea. I think my calls are connected (if i make a second call to the app i get the option of holding the first call) but it is worth giving it another try and check. – Redssie Sep 12 '18 at 08:00
  • It did the trick. I used this library react-native-callkit and I faced the same problem with Hold & Accent. I added [self.provider reportOutgoingCallWithUUID:currentCall.uuid connectedAtDate:[NSDate date]]; to the transactions completion handler right before [self.provider reportCallWithUUID:startCallAction.callUUID updated:callUpdate]; And I got Hold & Accept button and Send to voicemail button. Thanks. – elf2707 Oct 04 '18 at 22:16
  • Hey if this worked for you please upvote my answer... I could use the rep points! – Chad Barbe Feb 03 '19 at 17:12
-1

While you were sending CXCallUpdate object to CallKit before calling, make sure you kept supportsHolding value as true.

My CXCallUpdate looks something like below:

let callHandle = CXHandle(type: .phoneNumber, value: handle)
let callUpdate = CXCallUpdate()
if userName != nil{
       callUpdate.localizedCallerName = userName;
}
callUpdate.remoteHandle = callHandle
callUpdate.supportsDTMF = true
callUpdate.supportsHolding = true
callUpdate.supportsGrouping = false
callUpdate.supportsUngrouping = false
callUpdate.hasVideo = false  

Meaning of above different properties:

localizedCallerName = If you want to show name of user on system's call screen, otherwise phone number/email based on type of handle will be shown

supportsDTMF = On system's main screen, if you want to allow keypad numbers to be typed while call is running, if you make it false, keypad option get disabled.

supportsHolding = If you want your call to be held, when some other call get triggered, keep this property true

supportsGrouping = If you want to allow conference calling(Merge call option enabled in calling screen), then keep this one true

supportsUngrouping = Inverse of last one, After call getting merged(conference call), should allow it to ungroup or not.

hasVideo = If you support video call, the system will automatically start camera for you.

@Redssie, let me know if any further help related to Callkit required.

Mehul Thakkar
  • 12,440
  • 10
  • 52
  • 81
  • thank you for taking the time to help :) i set supports holding to true in every update i do. it still does not work with native calls. it works for calls inside the app. if i get 2 calls to the app it works. if 1 call is inside the app and one is on the native phone number, then i cannot hold the app call – Redssie Aug 21 '18 at 11:49
  • I have same code as above pasted and it is working perfectly fine. Make sure you kept supportsHolding on `CXCallUpdate`, as per your code, it looks you added on `CXProviderConfiguration` – Mehul Thakkar Aug 21 '18 at 12:29
  • If it is possible for you to share your code, I can surely give you the solution. I have worked on CallKit in last 1 month, so I can surely help you out. – Mehul Thakkar Aug 21 '18 at 12:41
  • What I think is, while making outgoing call, you might not be sending `CXCallUpdate` to `CXProvider`, just making transaction. Thats why it will not have any set variables as I described above. – Mehul Thakkar Aug 21 '18 at 12:47
  • this is my CXCallUpdate: let update = CXCallUpdate() update.remoteHandle = CXHandle(type: .phoneNumber, value: remoteNumber) update.hasVideo = videoEnabled update.supportsGrouping = false update.supportsHolding = true update.supportsUngrouping = false update.localizedCallerName = remoteDisplayName – Redssie Aug 22 '18 at 06:16
  • I set it in handleIncomingCall and CXStartCallAction. it works great if all the calls are to the app. if one call is on the native (gsm) number and one is on the app then holding does not work. – Redssie Aug 22 '18 at 06:19
  • not able to figure out, what problem makes your call to not show "holding" option. I have tested in my code, it is working perfectly fine in my case, whether it is my app's call, or native call or some other apps call. In my case, it is working perfectly fine for all cases. – Mehul Thakkar Aug 22 '18 at 12:47
  • Can you please remove this 2 lines in your code, and then try. `providerConfiguration.maximumCallsPerCallGroup = 1 providerConfiguration.maximumCallGroups = 3`, In my case, I have not added this lines. probably might work. – Mehul Thakkar Aug 22 '18 at 12:48
  • I tried doing that but it stil doesn't work. Thank you for your help. This was put on hold for a while so I will try to make it work some other time :) – Redssie Aug 27 '18 at 13:49
  • @MehulThakkar when i am holding my voip call and ansewering gsm call for me its no media can u help me out?? – Jeeva Dec 19 '19 at 05:22
  • @Jeeva : What do you mean by "its no media"? – Mehul Thakkar Dec 19 '19 at 05:35
  • @MehulThakkar https://stackoverflow.com/questions/51764123/hold-callkit-call-when-incoming-cellular-call/51946747?noredirect=1#comment104996092_51946747 – Jeeva Dec 19 '19 at 05:43
  • @MehulThakkar all other cases its working only on hold and accept gms call i am not able to hear any media – Jeeva Dec 19 '19 at 05:43
  • @Jeeva: Can you paste your some code related to this, possibly i can figure out what might be wrong. Otherwise in my case, it is working perfectly fine. – Mehul Thakkar Dec 19 '19 at 06:01
  • @MehulThakkar https://stackoverflow.com/q/59370625/6059583 this is my question – Jeeva Dec 19 '19 at 06:14