Skip to content

JuyeonYu/PermissionCenter

Repository files navigation

PermissionCenter

CI Status Version License Platform

Purpose of Permission Center

let you free steps for getting permission.

help you focus on the logic.


Imagine, now you want to open gallery. There are some inevitable steps.

  1. Check the permission
    1. If you can -> action
    2. If you can’t, the status will be
      1. Not determined -> request access permission
        1. If they accept the request -> action
      2. Denied -> induce them to access permission

These steps correspond to functions that require all permissions, not just the gallery.


How to use

PermissionCenter.video.action {
    // do something what you want
}

if you don't have permission, Permission Center present alert depending on status.

before using, change the message if you want

PermissionCenterString.cancel = "cancel"
PermissionCenterString.allowAllPhotos = "allow all photos"
PermissionCenterString.useCurrentPhoto = "use now"
PermissionCenterString.openSettings = "settings"
PermissionCenterString.notNow = "later"
PermissionCenterString.selectMorePhotos = "add photos"
PermissionCenterString.deniedUserTitle = "alert"
PermissionCenterString.deniedUserMessage = "you had denied the permission.\nyou can change it on settings."
PermissionCenterString.limitedPhotoUserMessage = "access to part of photos."

don't forget to add your property in plist.

<key>NSPhotoLibraryAddUsageDescription</key>
<string></string>
<key>NSPhotoLibraryUsageDescription</key>
<string></string>
<key>NSMicrophoneUsageDescription</key>
<string></string>
<key>NSLocationWhenInUseUsageDescription</key>
<string></string>
<key>NSLocationUsageDescription</key>
<string></string>
<key>NSLocationAlwaysUsageDescription</key>
<string></string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string></string>
<key>NSContactsUsageDescription</key>
<string></string>
<key>NSCameraUsageDescription</key>
<string></string>

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

iOS 10.0

Installation

PermissionCenter is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'PermissionCenter'

Author

JuYeonYu, [email protected]

License

PermissionCenter is available under the MIT license. See the LICENSE file for more info.