【发布时间】:2019-09-26 10:47:39
【问题描述】:
我正在使用 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")
}
}
谢谢。
【问题讨论】:
标签: iphone ios13 xcode11 callkit pushkit