Я хочу остановить уведомление Callkit во входящем вызове после отмены вызывающего абонента, и приемник еще не ответил, поэтому я получил, что пользователь отменил вызов с помощью другого уведомления Pushkit, у которого есть ключ без пропущенного. Успех < /p>
Это код < /p>
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void) {
print("didReceiveIncomingPushWith payload")
let payloadDictionary = payload.dictionaryPayload as NSDictionary
callOption.callData = payloadDictionary.value(forKey: "aps") as! [String : Any]
let user = callOption.callData["user"] as! [String : Any]
let callerID = user["name"] as! String
let hasVideo = true
let callUpdate = CXCallUpdate()
let uuid = UUID()
callUpdate.remoteHandle = CXHandle(type: .generic, value: callerID)
callUpdate.hasVideo = hasVideo
DispatchQueue.global().async {
self.callOption.ringingApi(otherId: self.callOption.callData["snd_id"] as! String)
}
let backgroundTaskIdentifier = UIApplication.shared.beginBackgroundTask(expirationHandler: nil)
if callOption.callData["typeCall"] as! String == "missingCall" {
self.endIncomingCall(userId: callOption.callData["snd_id"] as! String)
UIApplication.shared.endBackgroundTask(backgroundTaskIdentifier)
}
else {
self.displayIncomingCall(uuid: uuid, handle: callerID, hasVideo: hasVideo, userId: callOption.callData["snd_id"] as! String) { _ in
UIApplication.shared.endBackgroundTask(backgroundTaskIdentifier)
}
}
}
< /code>
Здесь функции, которые вызывались выше < /p>
func displayIncomingCall(uuid: UUID, handle: String, hasVideo: Bool, userId: String, completion: ((NSError?) -> Void)? = nil) {
providerDelegate?.reportIncomingCall(uuid: uuid, handle: handle, hasVideo: hasVideo, userId: userId, completion: completion)
}
func endIncomingCall( userId: String) {
providerDelegate?.reportTheCallerEndCall( userId: userId)
}
< /code>
И это делегат поставщика < /p>
/// Use CXProvider to report the incoming call to the system
func reportIncomingCall(uuid: UUID, handle: String, hasVideo: Bool, userId: String, completion: ((NSError?) -> Void)? = nil) {
// Construct a CXCallUpdate describing the incoming call, including the caller.
let update = CXCallUpdate()
update.remoteHandle = CXHandle(type: .phoneNumber, value: handle)
update.hasVideo = hasVideo
provider.reportNewIncomingCall(with: uuid, update: update) { error in
if error == nil {
let call = Call(uuid: uuid, handle: handle, userId: userId)
self.callManager.add(call: call)
}
completion?(error as NSError?)
}
}
func reportTheCallerEndCall(userId: String) {
guard let callIndex = self.callManager.findCallIndexInCallsArray(userId: userId) else { return}
provider.reportCall(with: self.callManager.calls[callIndex].uuid, endedAt: nil, reason: .unanswered)
}
Подробнее здесь: https://stackoverflow.com/questions/727 ... er-stop-it
Отмените входящий звонок, когда звонящий остановит его ⇐ IOS
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Как использовать CallScreeningService в Android, чтобы отклонить входящий звонок
Anonymous » » в форуме Android - 0 Ответы
- 30 Просмотры
-
Последнее сообщение Anonymous
-