Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide FaceTime button in CallKit UI

Tags:

ios

swift

callkit

I'm implementing CallKit support inside a VoIP application.

I was able to disable video button by setting supportsVideo to false in CXProviderConfiguration. Now the FaceTime button appeared.

I wanted to know if there is a way to disable FaceTime button in the default UI, since the app is handling internal enterprise numbers which has nothing to do with FaceTime.


Update: As stated in the answers below, it's possible to disable the button, but the caller number is lost (shown as Unknown). I want to preserve the number and disable the FaceTime button.


Update: Disabling FaceTime in iPhone settings disables the FaceTime button. However it's not a valid solution to the issue.


Update: Any changes to CXHandle type, including inserting characters not valid for a phone number into it, does not affect the issue - FaceTime button is still shown.

like image 457
Dan Tumaykin Avatar asked Dec 20 '16 15:12

Dan Tumaykin


3 Answers

I pulled my hair out for this problem, removing remoteHandle did disable the button, but you can't make call from System Call History anymore.

Finally figured out a perfect solution, I'd like to share.

Assume we support both Audio/Video.

  1. Init CXProviderConfiguration.

    let providerConfiguration = CXProviderConfiguration(localizedName: "yourConfigName")
    providerConfiguration.supportsVideo = supportsVideo
    providerConfiguration.supportedHandleTypes = [.generic, .phoneNumber, .emailAddress] // Pick your own supportedHandleTypes.
    
  2. Exclude remoteHandle when report incoming call.

    let update = CXCallUpdate()
    
    // Set hasVideo so it shows correct type on incomingCall screen.
    update.hasVideo = supportsVideo
    
    // Exclude remoteHandle so that the FaceTime button is disabled
    // update.remoteHandle = CXHandle(type: .generic, value: yourHandle)
    
  3. Important! Update the remoteHandle when ending the call, in func provider(_ provider: CXProvider, perform action: CXEndCallAction) delegate.

Excluding the remoteHandle when reportIncomingCall will lose the ability to call from System Call History. But you can update the call and set it up right before ending the call.

 func provider(_ provider: CXProvider, perform action: CXEndCallAction) {
    let update = CXCallUpdate()

    // Set the remoteHandle, so you can call from System Call History
    update.remoteHandle = CXHandle(type: .generic, value: yourHandle)
    provider.reportCall(with: uuid, updated: update)

    action.fulfill()
} 
like image 164
dichen Avatar answered Oct 30 '22 06:10

dichen


In a good news/bad news vein, I was able to disable the FaceTime button by clearing remoteHandle (not removed or hidden, just grayed out).

However, as a side effect, the Caller shows up as "Unknown", if you don't set the localizedCallerName property of the CXCallUpdate.
A call without a handle will have the side effect of not being pressable in Recents.

CXCallUpdate *callUpdate = [[CXCallUpdate alloc] init];
//callUpdate.remoteHandle = [[CXHandle alloc] initWithType:CXHandleTypeGeneric value:handle];
[self.provider reportNewIncomingCallWithUUID:uuid update:callUpdate completion:^(NSError* error) {}];
like image 5
Eli Burke Avatar answered Oct 30 '22 04:10

Eli Burke


I've got the FaceTime button disabled by following the same approach as for disabling the "Add Call" button, which doesn't break the caller name functionality, however weirdly the FaceTime button becomes active again if the user touches the speaker button. I don't see why would this behavior not be an Apple bug, so I just gave up on a proper fix.

edit: here's why: I was attributing a CXHandle to the CXCallUpdate only once the call was established, so at first the FaceTime button was disabled given that there was no CXHandle. Activating the speaker button somehow forced an update in the CallKit UI - at this point, there would exist a CXHandle already and thus the FaceTime button would get enabled.

like image 1
Gobe Avatar answered Oct 30 '22 06:10

Gobe