sparrowcode/PermissionsKit
소개
권한을 요청하고 상태를 확인하기 위한 범용 API입니다.
생산성 및 자동화측정된 스타 증가
- in 24h
- +1
- in 7 days
- +4
- in 15 days
- +7
- in 1 month
- +7
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
OriginalPermissionsKit
Universal API for requesting permissions and reading their status — .authorized, .denied & .notDetermined. Each permission ships as a separate product, so the app compiles only the ones it actually uses.
Installation
In Xcode: File → Add Package Dependencies → paste URL:
https://github.com/sparrowcode/PermissionsKit
Then pick the products you need. Add only those — every permission API you link is visible to App Review, and unused ones invite questions about why the app needs them.
Permissions
| Permission | Product | Key for Info.plist |
|---|---|---|
| Bluetooth | BluetoothPermission |
NSBluetoothAlwaysUsageDescription, NSBluetoothPeripheralUsageDescription |
| Calendar | CalendarPermission |
NSCalendarsUsageDescription, NSCalendarsFullAccessUsageDescription, NSCalendarsWriteOnlyAccessUsageDescription |
| Camera | CameraPermission |
NSCameraUsageDescription |
| Contacts | ContactsPermission |
NSContactsUsageDescription |
| FaceID | FaceIDPermission |
NSFaceIDUsageDescription |
| Health | HealthPermission |
NSHealthUpdateUsageDescription, NSHealthShareUsageDescription |
| Location | LocationPermission |
NSLocationAlwaysAndWhenInUseUsageDescription, NSLocationWhenInUseUsageDescription |
| Media Library | MediaLibraryPermission |
NSAppleMusicUsageDescription |
| Microphone | MicrophonePermission |
NSMicrophoneUsageDescription |
| Motion | MotionPermission |
NSMotionUsageDescription |
| Notification | NotificationPermission |
— |
| Photo Library | PhotoLibraryPermission |
NSPhotoLibraryUsageDescription, NSPhotoLibraryAddUsageDescription |
| Reminders | RemindersPermission |
NSRemindersUsageDescription, NSRemindersFullAccessUsageDescription |
| Siri | SiriPermission |
NSSiriUsageDescription |
| Speech Recognizer | SpeechRecognizerPermission |
NSSpeechRecognitionUsageDescription |
| Tracking | TrackingPermission |
NSUserTrackingUsageDescription |
Usage
Request a permission:
import PermissionsKit
import NotificationPermission
Permission.notification([.alert, .badge, .sound]).request {
// Called once the user answers the system dialog.
}
Read its status:
import PermissionsKit
import CameraPermission
let authorized = Permission.camera.authorized
[!WARNING] FaceID can't tell
.authorizedfrom.notDetermined— both come back as.notDetermined. Only.deniedis reliable.
Keys in Info.plist
Apple requires a usage description for most permissions. Get the key for a permission:
let key = Permission.bluetooth.usageDescriptionKey
[!NOTE] Use the key itself, not the description text — Xcode won't build otherwise.
Localisation
An xliff export creates the keys for you. Doing it by hand means adding an InfoPlist.strings file, selecting the languages in the inspector, and writing the keys there:
"NSCameraUsageDescription" = "Here description of usage camera";
관련 프로젝트 살펴보기
불러오는 중…