我们正在开发一个 VoIP 呼叫应用程序。我们正在使用
CallKit
和 PushKit
框架。一位用户最近报告说,他的 iPhone 不再接收 CallKit
推送,但几天前还可以正常工作。请注意,可变推送正在他的设备上运行。我们收集了设备的控制台日志,发现设备没有收到 voip 推送有效负载。
未安装防火墙且最近没有网络设置更改历史记录。
环境信息:
Device Model: iPhone Xs
iOS version: 15.6.1
Network Connectivity: Wifi
这就是我们注册的方式
PushKit
private func registerForVoIPPushes() {
self.voipRegistry = PKPushRegistry(queue: pushRegistryQueue)
self.voipRegistry.delegate = self
self.voipRegistry.desiredPushTypes = [.voIP]
}
我们这样遵守
PKPushRegistryDelegate
extension AppDelegate: PKPushRegistryDelegate {
func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType) {
let deviceToken = pushCredentials.token.map { String(format: "%02x", $0) }.joined()
updateVoIPToken(deviceToken)
}
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void) {
DDLogDebug("Incoming call voip push: \(payload.dictionaryPayload)")
handleIncomingCall(payload: payload.dictionaryPayload)
completion()
}
func pushRegistry(_ registry: PKPushRegistry, didInvalidatePushTokenFor type: PKPushType) {
DDLogDebug("didInvalidatePushTokenFor type: \(type)")
}
}
这就是服务器发送
voip
推送负载的方式
path = '/3/device/{0}'.format({deviceToken}})
request_headers = {
'apns-expiration': '0',
'apns-priority': '10',
'apns-topic': 'com.companyname.app.voip',
'apns-push-type':'voip',
'authorization': 'bearer {auth-token}'
}
# Open a connection the APNS server
conn = HTTP20Connection('api.push.apple.com:443')
conn.request(
'POST',
path,
payload,
headers=request_headers
)
resp = conn.get_response()
print(resp.status)
print(resp.read())
输出的http状态代码显示
200
,但推送实际上未发送。
相同的代码库在其他设备上运行良好。
我感谢任何帮助和建议。
谢谢。
func pushRegistry(_ registry: PKPushRegistry, didUpdate credentials: PKPushCredentials, for type: PKPushType) {
NSLog("pushRegistry:didUpdatePushCredentials:forType:")
let deviceToken = credentials.token.map { String(format: "%02.2hhx", $0) }.joined()
print("\(#function) token is: \(deviceToken)")
}