Я использовал приведенный ниже код для получения информации о звонках по номеру телефона службы поддержки, указанному в моем приложении. Но мое приложение отслеживает все телефонные звонки, которые не требуются. Мне нужен только номер службы поддержки, указанный в приложении.
Я использовал приведенный ниже код для получения действий
extension MainViewController: CXCallObserverDelegate {
func callObserver(_ callObserver: CXCallObserver, callChanged call: CXCall) {
let uuid = UUID()
let handle = CXHandle(type: .phoneNumber, value: SUPPORT_NUMBER)
let startCallAction = CXStartCallAction(call: uuid, handle: handle)
let transaction = CXTransaction(action: startCallAction)
Log.d("startTime, \(start)")
// Call disconnected / Ended
if call.hasEnded == true {
let diff = CFAbsoluteTimeGetCurrent() - start
Log.d("Took \(diff) seconds")
Log.d("connectionStatus, \(connectionStatus ?? "none")")
let duration = Int(diff)
var formattedDuration = STRING_EMPTY
Util().hmsFrom(seconds: duration) { hours, minutes, seconds in
let hours = Util().getStringFrom(seconds: hours)
let minutes = Util().getStringFrom(seconds: minutes)
let seconds = Util().getStringFrom(seconds: seconds)
formattedDuration = "\(hours):\(minutes):\(seconds)"
Log.d("\(hours):\(minutes):\(seconds)")
}
let callStat = UserDefaults.standard.string(forKey: "callStatus")
if callStat == "A" {
DispatchQueue.global(qos: .background).async {
self.postSupportCallCount(callStatus: callStat!, duration: formattedDuration)
}
} else {
formattedDuration = "00:00:00"
DispatchQueue.global(qos: .background).async {
self.postSupportCallCount(callStatus: callStat!, duration: formattedDuration)
}
}
}
// Call Dialing
if call.isOutgoing == true && call.hasConnected == false {
let callDuration = CFAbsoluteTimeGetCurrent() - start
connectionStatus = "R"
UserDefaults.standard.set(connectionStatus, forKey: "callStatus")
Log.d("Dialing \(callDuration) seconds")
Log.d("connectionStatus:\(String(describing: connectionStatus))")
// self.(callStatus: "Call Dialing", duration: "\(elapsed)")
}
// Call Ringing
if call.isOutgoing == false && call.hasConnected == false && call.hasEnded == false {
connectionStatus = "R"
UserDefaults.standard.set(connectionStatus, forKey: "callStatus")
let callDuration = CFAbsoluteTimeGetCurrent() - start
Log.d("OutGoing, elapsed:\(callDuration)")
Log.d("connectionStatus:\(String(describing: connectionStatus))")
Log.d("OutGoing \(callDuration) seconds")
// self.postSupportCallCount(callStatus: "Call OutGoing", duration: "\(elapsed)")
}
// Call Connected
if call.hasConnected == true && call.hasEnded == false {
connectionStatus = "A"
UserDefaults.standard.set(connectionStatus, forKey: "callStatus")
Log.d("connectionStatus:\(String(describing: connectionStatus))")
let callDuration = CFAbsoluteTimeGetCurrent() - start
Log.d("Dialing \(callDuration) seconds")
}
}
}
Любая помощь будет оценена.