I got many results when I tried with PKPushRegistryDelegate not called but nothing solved my issue. All are suggesting to check info.plist for background modes which is fine in my app. I enabled voip, background fetch, Remote notifications. Create VoIP certificate in apple developer account also. I wrote following lines in didFinishLanunchingWithOptions
let pushRegistry = PKPushRegistry(queue: DispatchQueue.main)
pushRegistry.delegate = self
pushRegistry.desiredPushTypes = [.voIP]
And delegate methods as below
func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType) {
if let token = String(bytes: pushCredentials.token, encoding: String.Encoding.utf8) {
print("Push token: \(token)")
}
}
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void) {
print("notification received")
print(payload)
}
func pushRegistry(_ registry: PKPushRegistry, didInvalidatePushTokenFor type: PKPushType) {
print("Token invalid")
}
But those delegate methods are never called. As VoIP certificate is only on production, I tried with production certificate and checked logs for push token but not found. Is there a way to debug it with development certificates? Am I missing anything here? Please advice.