Я хочу остановить уведомление 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
Программируем под IOS
-
Anonymous
1752144851
Anonymous
Я хочу остановить уведомление 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)
}
Подробнее здесь: [url]https://stackoverflow.com/questions/72726648/cancel-incoming-call-when-the-caller-stop-it[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия