iOS 13没有在后台获取VoIP推送通知 [英] iOS 13 not getting VoIP Push Notifications in background

查看:1161
本文介绍了iOS 13没有在后台获取VoIP推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm developing a softphone in Swift using CallKit and PushKit. Before iOS 13, VoIP notifications were working perfectly. But after the iOS 13 update, my app isn't getting VoIP push notification when it's in background. In foreground didReceiveIncomingPushWith is called, but in background it isn't called.

如何解决此问题?

代码

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将不再起作用.

If you build the app with Xcode 11 (and iOS 13 SDK) PushKit won't work any longer if you fail to report to CallKit.

在iOS 13.0和更高版本上,如果您无法报告对CallKit的呼叫,则 系统将终止您的应用.屡次未能举报电话可能 导致系统停止传递更多的VoIP推送通知 到您的应用.如果您想在不使用的情况下发起VoIP呼叫 CallKit,使用UserNotifications注册推送通知 框架而不是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

这篇关于iOS 13没有在后台获取VoIP推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆