我在这里挣扎了一段时间,可能这是我的错误,但我无法在任何地方找到它,这是一个答案.
我在某些方面实现了PushKit,但没有一个是有效的.
我已经添加了正确的后台模式,以正确的方式实现了回调,didUpdatePushCredentials
正在被正常调用...
但是,credentials: PKPushCredentials!
变量,给我一个错误指针......它不是空的......不是零...没有任何东西......它根本就没有值......它被分配了垃圾......因为这个原因..我收到了EXC_BREAKPOINT ..
我试过3种不同的设备......行为相同......
我已经创建了VoIP推送证书......
我以不同的方式做到了:
总是一样......
这是代码:
extension AppDelegate : PKPushRegistryDelegate {
func registerForVoipPush() {
self.registry = PKPushRegistry(queue:nil)
if self.registry != nil {
self.registry!.delegate = self
self.registry!.desiredPushTypes = Set<String>(arrayLiteral: PKPushTypeVoIP)
}
//let notificationSettings = UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories:nil)
//UIApplication.sharedApplication().registerUserNotificationSettings(notificationSettings)
}
func pushRegistry(registry: PKPushRegistry!, didUpdatePushCredentials credentials: PKPushCredentials!, forType type: String!) {
//print out the VoIP token. We will use this to test the nofications.
NSLog("voip token: \(credentials.token)") …
Run Code Online (Sandbox Code Playgroud)