pushRegistry:didUpdate:pushCredentials未被调用

Gru*_*kes 0 voip ios pushkit

查看过去关于此的问题,但这些问题的答案已经应用于我的项目,但是没有调用pushRegistry()委托方法.

首先是这里的代码:

import UIKit
import PushKit
import UserNotifications

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate{

    var window: UIWindow?
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        let notificationSettings  = UIUserNotificationSettings(types: [.badge, .sound, .alert], categories: nil)
        application.registerUserNotificationSettings(notificationSettings)

        UNUserNotificationCenter.current().delegate = self
        UIApplication.shared.registerForRemoteNotifications()

        let voipRegistry = PKPushRegistry(queue: DispatchQueue.main)
        voipRegistry.desiredPushTypes = Set([PKPushType.voIP])
        voipRegistry.delegate = self;

        return true
    }
...
}

extension AppDelegate: PKPushRegistryDelegate {
    func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType) {
        NSLog("voip token: \(pushCredentials.token)")
    }
Run Code Online (Sandbox Code Playgroud)

已启用以下应用程序功能: - 推送通知 - 后台模式 - 后台获取 - 远程通知

我正在使用Xcode 9.1 Beta,它不再具有Voip作为显式功能,显然这不再需要,导入PushKit就足够了.

在配置门户上,已为应用程序ID启用了"推送通知".(已经生成了Void Push证书,但显然不能使用它来发送推送)

Gru*_*kes 5

显然这不再需要,导入PushKit就足够了.

我读了几篇帖子说这个但不正确.为了使工作正常,我不得不手动编辑info.plist以将voip添加到后台模式列表中.

 <string>voip</string>
Run Code Online (Sandbox Code Playgroud)

Apple在玩什么?为什么他们仍然需要从Xcode中删除它作为一种功能呢?