ios - PushKit PKPushRegistryDelegate 没有得到回调

标签 ios swift

将我的应用升级到 Xcode8/Swift 3 后,我不再收到来自 PKPushRegistryDelegate 的回调。

我已验证 Apple´s Voice Over IP (VoIP) Best Practices 中的所有步骤.

我的设备记录了以下可能相关的内容:

callservicesd[92] : [WARN] Ignoring voipRegister request because either no bundleIdentifier could be determined (0) or no environment could be determined (1)

我的应用程序委托(delegate):

var voipRegistry: PKPushRegistry!

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
  voipRegistry = PKPushRegistry(queue: DispatchQueue.main)    
  voipRegistry.delegate = self    
  voipRegistry.desiredPushTypes = Set([.voIP])    
}

extension AppDelegate: PKPushRegistryDelegate {    
    func pushRegistry(_ registry: PKPushRegistry, didInvalidatePushTokenForType type: PKPushType) {        
        print("didInvalidatePushTokenForType")        
    }

    func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, forType type: PKPushType) {        
        print("Incoming voip notfication: \(payload.dictionaryPayload)")
    }

    func pushRegistry(_ registry: PKPushRegistry, didUpdate credentials: PKPushCredentials, forType type: PKPushType) {               
        print("voip token: \(credentials.token)")        
    }   
}

最佳答案

我想我必须在我的目标功能下启用“推送通知”:

enter image description here

关于ios - PushKit PKPushRegistryDelegate 没有得到回调,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40829550/

相关文章:

ios - 从另一个类访问 IBOutlet 属性

ios - 通过代码 Objective-c 隐藏按钮时出错

ios - iOS 中的多模板应用

ios - UITabBarController 选项卡栏项目仅在选中时显示

ios - 如何计算不同时区的两个 NSDate 对象之间的天数差异?

swift - 将全局函数分离到自己的文件中?

ios - iPhone 锁定时如何隐藏 iOS 14 WidgetKit 内容?

ios - iPhone 6 模拟器上的 indexPath.row 计算不正确,但 4s/5/5s/6plus 上不正确

ios - Swift:如何在写入时不断调整 UICollectionViewCell 高度以适应 UITextView?

ios - 在我正在创建的框架中的 XCTest 期间无法加载自定义字体