gpt4 book ai didi

iphone - iOS 13 无法在后台获取 VoIP 推送通知

转载 作者:行者123 更新时间:2023-12-03 18:34:06 24 4
gpt4 key购买 nike

我正在使用 CallKit 和 PushKit 在 Swift 中开发软件电话。在 iOS 13 之前,VoIP 通知运行良好。但在 iOS 13 更新后,我的应用程序在后台时无法收到 VoIP 推送通知。在前台调用 didReceiveIncomingPushWith,但在后台不调用它。

如何解决这个问题?

代码

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
print("\(#function)")
let voipPushResgistry = PKPushRegistry(queue: nil)
voipPushResgistry.delegate = self
voipPushResgistry.desiredPushTypes = [PKPushType.voIP]

return true
}

func pushRegistry(_ registry: PKPushRegistry, didInvalidatePushTokenFor type: PKPushType) {
print("\(#function) token invalidated")
}

func pushRegistry(_ registry: PKPushRegistry, didUpdate credentials: PKPushCredentials, for type: PKPushType) {
let deviceToken = credentials.token.reduce("", {$0 + String(format: "%02X", $1) })
print("\(#function) token is: \(deviceToken)")
}

func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void) {
print("\(#function)")
print("It worked..")
if type == .voIP {
print("Uygulama aktif")
}
}

谢谢。

最佳答案

如果您使用 Xcode 11(和 iOS 13 SDK)构建应用程序,如果您无法向 CallKit 报告,PushKit 将不再工作。

On iOS 13.0 and later, if you fail to report a call to CallKit, the system will terminate your app. Repeatedly failing to report calls may cause the system to stop delivering any more VoIP push notifications to your app. If you want to initiate a VoIP call without using CallKit, register for push notifications using the UserNotifications framework instead of PushKit.

https://developer.apple.com/documentation/pushkit/pkpushregistrydelegate/2875784-pushregistry

关于iphone - iOS 13 无法在后台获取 VoIP 推送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58115125/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com