问题描述
我怎么知道我的设备被阻止接收VoIP通知?
How do I know that my device is blocked from receiving VoIP notifications?
应用程序接收3-4次后将停止接收VoIP通知.我了解从iOS 13开始,VoIP通知应报告给CallKit.即使在向CallKit报告后,我仍在解决不接收VoIP通知的问题.
The application stops receiving VoIP notifications after receiving for 3-4 times. I understand that from iOS 13 VoIP notifications should be reported to CallKit. Even after reporting to CallKit, I'm going through this issue of not receiving VoIP notifications.
我们将apns-expiration设置为0,将优先级设置为即时(10).
We have set apns-expiration to 0 and the priority to immediately(10).
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void) {
dictPayload = payload.dictionaryPayload[K.KEY.APS] as? [String : Any]
if dictPayload![K.KEY.ALERTTYPE] as? String == K.KEY.VOIPCALL {
self.displayIncomingCall(uuid: appDelegate.uudiForCall, handle: (self.dictPayload!["handle"] as? String)!) { (error) in
}
CallProviderDelegate.sharedInstance.callDidReceiveIncomingCallfromKill(callInfo: self.dictPayload!)
} else if dictPayload![K.KEY.ALERTTYPE] as? String == K.KEY.PUSHTOTALK {
isPTTON = true
pjsua_set_no_snd_dev()
CallHandler.sharedCallManager()?.muteCall(true)
CallHandler.sharedCallManager()?.setAudioSessionSpeaker()
CallProviderDelegate.sharedInstance.callDidReceivePTTFromKIll(callFromName: dictPayload!["title"] as? String, callfromExt: dictPayload![K.KEY.BODY] as? String)
} else if dictPayload![K.KEY.ALERTTYPE] as? String == K.KEY.HANGUP {
isPTTON = false
CallProviderDelegate.sharedInstance.endCallFromPTT(endCallUDID: appDelegate.uudiForCall)
}
}
func displayIncomingCall(
uuid: UUID,
handle: String,
hasVideo: Bool = false,
completion: ((Error?) -> Void)?
) {
let update = CXCallUpdate()
update.remoteHandle = CXHandle(type: .phoneNumber, value:(handle))
CallProviderDelegate.sharedInstance.provider.reportNewIncomingCall(with: uuid, update: update, completion: { error in })
}
XCODE:11.3.1,SWIFT:4.2及以上;iOS:13.0 +
XCODE: 11.3.1,SWIFT: 4.2 &iOS: 13.0 +
自最近两个月以来,我一直在试图解决此问题,但无法解决.请帮助我
I am trying to figure out this issue since the last 2 months but not able to resolve it. Please help me
谢谢.
推荐答案
实际上,似乎您并没有为每个VoIP推送通知报告一个新的来话呼叫.的确,当有一个活动的CallKit呼叫时,您可以在不报告新呼入呼叫的情况下接收VoIP推送,但这并不像看起来那样简单.由于CallKit和PushKit是异步的,因此不能保证在收到 K.KEY.PUSHTOTALK
或 K.KEY.HANGUP
类型的推送时,呼叫已经开始.此外,如果 dictPayload
为nil,您将无法报告新的来电.
Actually, it seems that you aren't reporting a new incoming call for every VoIP push notification. It's true that when there is an active CallKit call, you can receive VoIP pushes without reporting a new incoming call, but it's not as simple as it might seem. Since CallKit and PushKit are asynchronous, you are not guaranteed that when you receive a push of type K.KEY.PUSHTOTALK
or K.KEY.HANGUP
the call has already started. Moreover, if dictPayload
is nil, you fail to report a new incoming call.
无论如何,我认为代码中最大的问题是您没有调用 pushRegistry(:didReceiveIncomingPushWith ...)
方法的完成处理程序.您应该执行以下操作:
Anyway, I think that the biggest problem in your code is that you're not calling the completion handler of the pushRegistry(:didReceiveIncomingPushWith...)
method. You should do the following:
self.displayIncomingCall(uuid: appDelegate.uudiForCall, handle: (self.dictPayload!["handle"] as? String)!) { (error) in
completion() // <---
}
和
CallProviderDelegate.sharedInstance.provider.reportNewIncomingCall(with: uuid, update: update, completion: { error in
completion()
})
// or
CallProviderDelegate.sharedInstance.provider.reportNewIncomingCall(with: uuid, update: update, completion: completion)
这篇关于VOIP通知丢失或延迟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!