Hide FaceTime button in CallKit UI

2019-04-10 16:21发布

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.

4条回答
对你真心纯属浪费
2楼-- · 2019-04-10 16:35

It's can really disable the FaceTime button by clearing remoteHandle as @Eli Burke says, but the side effect is disabling calling from Recents. I don't know why.

查看更多
We Are One
3楼-- · 2019-04-10 16:36

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) {}];
查看更多
迷人小祖宗
4楼-- · 2019-04-10 16:36

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.

查看更多
爱情/是我丢掉的垃圾
5楼-- · 2019-04-10 16:55

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()
} 
查看更多
登录 后发表回答