This repository has been archived by the owner on Feb 27, 2019. It is now read-only.
Enabling use of PermissionScope on a per-request basis #39
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
NOTE: I haven't been using PermissionScope long, so it's definitely possible I'm tackling this the wrong way, but sometimes I'd like to utilize PermissionScope from within my own app's UI, e.g. to request notification permissions from a UISwitch in my app's interface.
In commit a4fc02d some of the API was opened up which would allow this.
But when using it I discovered situations that weren't working, like if the user had disabled/denied permissions, the alert view couldn't be shown by PermissionScope since it's primary window wasn't being shown. So I modified things to allow me to pass in a view controller on the
request*()
calls, which can then be passed into the declined/denied alerting methods in those situations.Next issue was I needed a way to know when the permission request was finished, so I made the authChangeClosure and cancelClosure public, allowing me to set them directly. (Feels a bit hacky, but wasn't sure if it was worth modifying the
request*()
methods to allow for an optional set of closures instead?)Finally, in the situation where the permissions were declined/denied, and we're showing the alert to let them know and help them fix it, I needed to know that this had happened, so I created a new public closure property called disabledOrDeniedClosure, and it's called when either of those alert views are shown.