swifticloudcloudkit

How to detect when user disables iCloud per app in settings


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

enter image description here


Solution

  • You can accomplish this with CloudKid.

    By registering to CKAccountChanged Notification.

    Example

    import CloudKit
    
    ...
    
    NotificationCenter
        .default
        .addObserver(forName: .CKAccountChanged, 
                      object: nil, 
                       queue: nil) { notification in
    
                       }