Exemplo n.º 1
0
    private void Run()
    {
        Debug.Log("Example 7 - Account Status");

        // This is the Core Foundation way of checking if the user has changed
        // This method is NOT recommended by apple. But is the only option if you
        // are not using CloudKit (and are just using key value storage)

        Token        = NSFileManager.DefaultManager().UbiquityIdentityToken;
        Unsubscriber = ICloudNotifications.AddIdentityDidChangeObserver(OnCloudIdentityChanged);

        // If your using cloud kit...apple has this to say:
        // CloudKit clients should not use this token as a way to identify
        // whether the iCloud account is logged in. Instead, use
        // accountStatusWithCompletionHandler: or
        // fetchUserRecordIDWithCompletionHandler:
        // https://developer.apple.com/documentation/foundation/nsfilemanager/1408036-ubiquityidentitytoken?language=objc

        // This is the cloudkit way
        // Listen for the accountStatusChanged notification

        // Apple says... "Notification posted when the status of the signed-in iCloud account may have changed."
        // This notification will fire for a number of reasons, not all of them will be related to signing in or
        // out of iCloud. For instance, toggling the iCloud Drive permission in iCloud settings will cause this
        // to fire

        CKContainer.AddAccountChangedNotificationObserver(AccountStatusChanged);

        // At this point you should sign in or out of iCloud to update the account stauts.
        Debug.Log("Account status notification handlers attached. Sign in or out of iCloud ot update.");
        Debug.Log("Waiting for change in account status...");
    }
Exemplo n.º 2
0
    public void Can_add_account_changed_notification_observer()
    {
        var unsub = CKContainer.AddAccountChangedNotificationObserver((notification) => { });

        Assert.IsNotNull(unsub);
    }