IOS 16 callkit answering in lockscreen

i have a problem when answering call on via callkit ui if my app is in lockscreen and killed state. I am currently using skyway for the audio and video call

issue description

  • when the call receiveranswersr the via callkit ui , the receiver will not receive an answer till he will visit the app .

this issue doesn't happen on ios 15 version

Post not yet marked as solved Up vote post of fdcMartin Down vote post of fdcMartin
2.4k views

Replies

I realise this is a little late but we ran in to a similar issue and managed to solve it by making sure the device is unlocked before fulfilling the CXAnswerCallAction.

The code looked like this:


func provider(_ provider: CXProvider, perform action: CXAnswerCallAction) {
	checkUnlockedAndFulfill(action: action, counter: 0)
}

private func checkUnlockedAndFulfill(action: CXAnswerCallAction, counter: Int) {
	if UIApplication.shared.isProtectedDataAvailable {
		action.fulfill()
	} else if counter > 180 { // fail if waiting for more then 3 minutes
		action.fail()
	} else {
		DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
			self.checkUnlockedAndFulfill(action: action, counter: counter + 1)
		}
	}
}

Hopefully this helps.

  • Hi Radther,thanks for your answer. I'm trying to implement this on flutter. Do you know where should I put that code? Could AppDelegate.swift be the right place? Thanks

  • This seems to help me when my app is locked and in the background, but when locked + killed the app doesn't start up once the call has been answered and unlocked.

  • I've had this bug for over a year. THANK YOU! Thought I was going crazy. This worked perfectly.

Add a Comment

Hello Team

   Facing same issue tried above solution not work for me please help.

Hi there, I got this problem even IOS < 16, any new solution now?

Hello, maybe I'm a bit late to the party but what worked for me when the app is killed and user delays unlocking for seconds is @Radther answer but adding UIApplication.shared.applicationState == .active as AND condition

func provider(_ provider: CXProvider, perform action: CXAnswerCallAction) {
	checkUnlockedAndFulfill(action: action, counter: 0)
}

private func checkUnlockedAndFulfill(action: CXAnswerCallAction, counter: Int) {

	if UIApplication.shared.isProtectedDataAvailable,
     UIApplication.shared.applicationState == .active // <-- This
    {
      // Add your videocall view to view hierarchy here, not before 
		  action.fulfill()

	} else if counter > 30 { // Timeout in seconds

		action.fail()

	} else {

		DispatchQueue.main.asyncAfter(deadline: .now() + 1) {

			self.checkUnlockedAndFulfill(action: action, counter: counter + 1)
		}
	}
}