watchospushkit

Apple Watch - PushKit delegate is not called


Trying to use PKPushKit to update watch WidgetKit complications. Here is the code inside watch app delegate:

let pushRegistry = PKPushRegistry(queue: nil)

func applicationDidBecomeActive() {
    pushRegistry.delegate = self
    pushRegistry.desiredPushTypes = [.complication]
}

func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType) {
    let token = pushCredentials.token.reduce("") { $0 + String(format: "%02x", $1) }
    print("PushToken: " + token)
}

applicationDidBecomeActive is being called and pushRegistry is updated, but none of the delegate methods are being called. The Watch App has push notifications capability already.


Solution

  • I believe this is an issue with not using ClockKit for complications. I've been told by Apple Engineers during a WWDC lab that these are no longer called as soon as you migrate to using WidgetKit for your complications. This is super frustrating for my use case as well. I will update this answer if I learn more.