简体   繁体   中英

How to resume a CallKit call on hold

I'm using CallKit in my Objective-C app.

I'm able to make a call using CallKit. If a second call comes in, I successfully set it on hold. When I end the second call, the

- (void)provider:(CXProvider *)provider performEndCallAction:(CXEndCallAction *)action

and the

- (void)callObserver:(CXCallObserver *)callObserver callChanged:(CXCall *)call

methods do get called.

But the

 - (void)provider:(CXProvider *)provider performSetHeldCallAction:(CXSetHeldCallAction *)action

method won't get called automatically.

Do I have to trigger it manually, for example from a method like

- (void)performHoldCallActionWithUUID:(NSUUID *)uuid onHold:(BOOL)onHold {
    //...

    CXSetHeldCallAction *holdCallAction = [[CXSetHeldCallAction alloc] initWithCallUUID:uuid onHold:onHold];
    CXTransaction *transaction = [[CXTransaction alloc] initWithAction:holdCallAction];

    [self.callKitCallController requestTransaction:transaction completion:^(NSError *error) {
        //...
    }];
}

or is there a way to make the provider call it "automatically", when the second call is ended by the user?

Thanks.

The system only notify you that a call is ended (with UUID) and a call status was changed, but it don't change your call status, you need do this manually.

An option is quit from on hold when system notify you through

- (void)callObserver:(CXCallObserver *)callObserver callChanged:(CXCall *)call

For do it, you receive the call that was changed and you can access call's UUID. You can know that call was ended and compare UUID to know if this call is app's call. If:

  • app has an active call,
  • and it is on hold,
  • and call received as parameter in method isn't your call (UUIDs aren't equals)
  • and the call received as parameter was ended,

then you can quit from on hold your call with:

CXSetHeldCallAction *holdCallAction = [[CXSetHeldCallAction alloc] initWithCallUUID:appCallUUID onHold:NO];
CXTransaction *transaction = [[CXTransaction alloc] initWithAction:holdCallAction];

[self.callKitCallController requestTransaction:transaction completion:^(NSError *error) {
    //...
}];

I would like help you more writing code, but I am writing in a mobile phone and i don't remember how to access call's info.

I hope that it is help you

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM