Permit framework provides a universal API for querying the permission status of different kinds of permissions, in an abstracted format with only what the user needs to know.
Ready to use of iOS 12+. For iOS only right now.
Permit can be installed throught Cocoapods
. CocoaPods is a dependency manager for Apple Platforms. For usage and installation instructions, visit their website. To integrate using CocoaPods, specify it in your Podfile
:
pod 'Permit'
Permit
aims to provide a very minimal API for accessing and requesting permissions for different use cases. For a list of available use cases, see available use cases.
Request status between isAuthorized
, isDenied
and isNotDetermined
like:
if Permit.isAuthorized(usecase: .camera) {
// do any stuff for authorised
} else {
// we know that it is either denied or not-determined..
// so, request permission which handles both usecases internally.
Permit.requestPermission(usecase: type, showPopupIfNeededOn: self) { result in
switch result {
case let .success(type):
// do permission granted stuff
case let .failure(error):
// show error dialog
}
}
You can also provide custom alert configs like:
struct DeniedAlertConfig: AlertConfig {
var title: String
var message: String
var cancelButtonText: String
var settingsButtonText: String
init() {
self.title = "Demo Denied Alert Title"
self.message = "Demo Denied Alert Message"
self.cancelButtonText = "Cancel"
self.settingsButtonText = "Settings"
}
}
And use them while requesting permissions as:
let config: AlertConfig = DeniedAlertConfig()
Permit.requestPermission(usecase: type,
showPopupIfNeededOn: self,
settingsDialogConfig: alertConfig) { result in }
- Camera
- Calendar
- Contacts
- Location When In Use
- Location Always
- Microphone
- Notifications
- Photos
- More coverage on Permission across Apple platforms.
- More platform support - MacOS, TvOS etc.
- Segregation between frameworks so that only needed ones can be used.
- [Maybe?] Custom alerts for pre-asking some permissions.
We are welcoming any and all contributions in the framework from the community. We should together strive to make this framework better for everyone of us. To contribute:
- Fork this repository as your own.
- For issues: Please indicate that you will pickup the issue and fix it. Discuss the approach with the moderators and continue to build that fix. Raise the Pull Request to
main
branch along with issue. - For new features: Please indicate the need for new features, and any approach you might have to build that. Discuss the approach with moderators and build it! Raise the Pull Request to
main
. - Please make use of tags while adding issues, such as
version numbers
,feature
,bug
etc. - We look forward to your contributions!