I am developing a voip app, which uses Callkit to show System UI for incoming calls.
To test the incoming call, I triggered it from my app like below
let callHandle = CXHandle(type: .phoneNumber, value: "+9197xxxxxxxx")
let callUpdate = CXCallUpdate()
callUpdate.remoteHandle = callHandle
callUpdate.supportsDTMF = true
callUpdate.supportsHolding = true
callUpdate.supportsGrouping = false
callUpdate.supportsUngrouping = false
callUpdate.hasVideo = false
UIApplication.shared.beginBackgroundTask {
print("Error")
}
DispatchQueue.main.asyncAfter(deadline: .now() + 10.0) {
self.callKitProvider.reportNewIncomingCall(with: UUID(), update: callUpdate) { (error) in
print(error)
}
}
which works fine when app is in foreground, but when I put the device in locked state it throws error as "Error Domain=com.apple.CallKit.error.incomingcall Code=3 "(null)""
Please help. Thanks in Adavance!
DND was the problem as @AntonioM suggested in the comments, Switching it off works fine.