I'm currently observing .NSUbiquityIdentityDidChange
which I read should be triggered whenever an iCloud related change occurs but it's not being triggered if I disable iCloud for my app in Settings > Apple ID > iCloud > Apps using iCloud
You can accomplish this with CloudKid.
By registering to CKAccountChanged
Notification.
import CloudKit
...
NotificationCenter
.default
.addObserver(forName: .CKAccountChanged,
object: nil,
queue: nil) { notification in
}