Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CloudKit discoverability permissions. #30

Closed
evermeer opened this issue Dec 5, 2016 · 7 comments
Closed

Add CloudKit discoverability permissions. #30

evermeer opened this issue Dec 5, 2016 · 7 comments

Comments

@evermeer
Copy link
Contributor

evermeer commented Dec 5, 2016

For adding CloudKit discoverability permissions you could use this code. You do have to be aware that this is an async call.

        let container = CKContainer.default()
        container.status(forApplicationPermission: CKApplicationPermissions.userDiscoverability, completionHandler: { applicationPermissionStatus, error in
                 // handle applicationPermissionStatus for statuses like
                 // CKApplicationPermissionStatus.Granted, .Denied, .CouldNotComplete, .InitialState
        })


        let container = CKContainer.default()
        container.accountStatus(completionHandler: {status, error in
            switch status {
            case .available, .restricted:
                container.requestApplicationPermission(CKApplicationPermissions.userDiscoverability,  completionHandler: { applicationPermissionStatus, error in
                          // handle applicationPermissionStatus for statuses like CKApplicationPermissionStatus.Granted, .Denied, .CouldNotComplete, .InitialState
                })
            case .couldNotDetermine, .noAccount: break
                // Ask user to login to iCloud
            }
        })
@ennioma
Copy link
Owner

ennioma commented Dec 5, 2016

Thanks for the suggestion, I'll add it soon

@ennioma
Copy link
Owner

ennioma commented Dec 8, 2016

Hi @evermeer,
I've added ArekCloudKit in the branch https://github.com/ennioma/arek/tree/addCloudKitPermission. It's not actually merged to develop because I need to test it more.

I'd love to hear your feedback on this branch, I've just integrated your example into Arek.

Thanks!

@evermeer
Copy link
Contributor Author

evermeer commented Dec 9, 2016

Thanks @ennioma I will give it a test drive this weekend

@ennioma
Copy link
Owner

ennioma commented Dec 17, 2016

@evermeer did you have any chance to test the update on that branch? Thanks!

@evermeer
Copy link
Contributor Author

Yes, I did change some code and made a pull request for it. For managing the permitions you need 2 calls. The 1st is to see if the user is loged in into iCloud and the second is to ask for discoverability permissions. See the PR

@ennioma
Copy link
Owner

ennioma commented Dec 18, 2016

Sorry I missed that :)

I take a look soon!

@ennioma
Copy link
Owner

ennioma commented Dec 18, 2016

PR #48 merged.

@ennioma ennioma closed this as completed Dec 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants