NSUbiquityIdentityDidChangeNotification not working for app extension

I'm developing a autoFill credential provider extension.


The extension uses an iCloud file which is sharing data between the main application and the extension. Reusing the code to manage iCloud files, I'm not seeing any notication that iCloud has been disabled (or reenabled) for the main application inside the extension.


This issue is made worse by the fact that extensions may be terminated - or not. So whilst an extension continues to run it appears to maintain the same iCloud state from startup. Calls to NSFileManager.defaultManager.ubiquityIdentityToken always return the same value within the extension (and NSUbiquityIdentityDidChangeNotification is never posted). This means after informing the end user that iCloud needs to be enabled, it is unable to detect that it has been enabled, until the extension process is eventually terminated and then restarted.