Enumerator doesn't enumerate changes on PushKit notification

I'm seeing a notification come in through PushKit for my FileProvider extension on iOS:

func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void) { 
print("FileProvider::pushDelegate::didReceiveIncomingPush", type.rawValue, payload.dictionaryPayload)
    }

For example, I'm seeing:

FileProvider::pushDelegate::didReceiveIncomingPush PKPushTypeFileProvider [AnyHashable("aps"): {

    "" = "{\"container-identifier\":\"NSFileProviderRootContainerItemIdentifier\"}";

}]

But I'm not getting a ping to enumerateChanges in the enumerator that is currently active. What would cause this?

Replies

Are you using the "default" domain, or you are adding domains through +[NSFileProviderManager addDomain:] ? See https://developer.apple.com/documentation/fileprovider/nsfileproviderextension/2882088-domain?language=objc

If you are adding domains through the manager, you need to also pass the domain parameter in the push payload, so the system knows to which domain the notification should be sent.

See the "Send Notifications" section here: https://developer.apple.com/documentation/fileprovider/content_and_change_tracking/tracking_your_file_provider_s_changes/using_push_notifications_to_signal_changes?language=objc

  • Hi @clenart,

    I'm not setting a domain, no. If I look at the above log, I'm seeing "" = "{\"container-identifier\":\"NSFileProviderRootContainerItemIdentifier\"}";, is that maybe the issue? Because as far as I can tell, the container-identifier should be the JSON key instead of a JSON object in the value.

    However, I'm not certain of this, as the documentation page mentions:

    { container-identifier = "<identifier>" domain = "<domain identifier>" }

    Which, to me, doesn't look like valid JSON. Should it also be wrapped in the aps dictionary?

  • Indeed, be sure that container-identifier is a JSON key in the payload. Your logs indicate that your push notification payload has a key of "", mapped to a value which is the serialized JSON payload which you intended to send.

    The documentation page does not have valid JSON, thanks for mentioning that. We will update that.

  • Thank you for your answer, @clenart! We've deployed the fixes to our backend, but I'm still not seeing enumerateChanges triggered, even though PushKit is logging that there's a push coming in for .fileProvider.

    The log is now FileProvider::pushDelegate::didReceiveIncomingPush PKPushTypeFileProvider [AnyHashable("container-identifier"): NSFileProviderRootContainerItemIdentifier]

    I'm using a real device, with the debugger attached, when running from Xcode. Should I just archive a build and drag it to my iPhone from Finder instead, or should it just work? Or should the container-identifier JSON be wrapped in the aps key as well? That's not clear to me from documentation.