Search code examples
iospush-notificationdelegatesswift-protocolspushkit

No type or protocol named PKPushRegistryDelegate


I'm adding PushKit notification to my app and have stumbled into the error above.

What I have done:

  1. Enabled push notification
  2. Enabled remote notification in background mode
  3. Added linked framework PushKit.framework

I extended my AppDelegate with PKPushRegistryDelegate and implemented pushRegistry method:

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, PKPushRegistryDelegate {
func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, forType type: PKPushType) {

}
.
.
.

Everything seems ok but when I build I get the error:

No type or protocol named PKPushRegistryDelegate

I also tried with extension in that case I got a different error:

Cannot find protocol declaration for 'PKPushRegistryDelegate'

I'm guessing that something is missing but cannot find what. Can anyone help me?

p.s. I'm using xcode 9 and swift 4


Solution

  • Imported #import in Bridging-Header.h and now it works.