Complication PushKit is not received in the background

It is received fine when the watch app is in the foreground.

Code sample:

import Foundation
import PushKit

final class PushNotificationProvider: NSObject {
    let registry = PKPushRegistry(queue: nil)
    
    override init() {
        super.init()
        registry.delegate = self
        registry.desiredPushTypes = [.complication]
    }

    func pushRegistry(_ registry: PKPushRegistry, didUpdate pushCredentials: PKPushCredentials, for type: PKPushType) {
        Log("token received")
    }
    
    func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void) {
        Log("push received")
        completion()
    }
}

Watch app:

import SwiftUI

@main
struct XX_Watch_App: App {
    @WKApplicationDelegateAdaptor var appDelegate: XXWearableAppDelegate
    
    private let push = PushNotificationProvider()
    
    var body: some Scene {
        WindowGroup {
            AppView(...)
        }
    }
}

There are a lot of reasons that this may not be working as you expect.

For starters, are you using the old (and deprecated in watchOS 10) ClockKit, or the new WidgetKit?

In either case, there are limits on how much background processing your app will get, how much background data transfer it will do and how many complication notifications can be sent. If you have been exceeding these limits during your tests, that would explain the issue you are seeing.

Also, complications will be updated by the system according to the timeline and the push notification, and not necessarily give your app runtime. If your use case requires that each complication update is to be made by the app upon receiving a notification, that may not be the best strategy. A better approach would be to move complex and time consuming tasks off the watch to your push server.

Hi, thank you for responding. I'm using WidgetKit, which allow about 4 updates per hours, but sometimes, we need immediate updates. Would be great if we could force update from the Phone, but that is not working with WidgetKit.

Also, in the documentation https://developer.apple.com/documentation/pushkit there is no mention that pushKit only works with clockKit, which is useless since you cannot add those to newer watchOS devices.

Complication PushKit is not received in the background
 
 
Q