PermissionsKit
  • November 30, 2023

Universal API for request permission and get its statuses — available .authorized.denied & .notDetermined.

               

Navigate


Permissions

Icon Permission Key for Info.plist Get Status Make Request
Bluetooth NSBluetoothAlwaysUsageDescription, NSBluetoothPeripheralUsageDescription
Calendar NSCalendarsUsageDescription, NSCalendarsFullAccessUsageDescription, NSCalendarsWriteOnlyAccessUsageDescription
Camera NSCameraUsageDescription
Contacts NSContactsUsageDescription
FaceID NSFaceIDUsageDescription ☑️
Health NSHealthUpdateUsageDescription, NSHealthShareUsageDescription
Location NSLocationAlwaysAndWhenInUseUsageDescription NSLocationWhenInUseUsageDescription
Media Library NSAppleMusicUsageDescription
Microphone NSMicrophoneUsageDescription
Motion NSMotionUsageDescription
Notification
Photo Library NSPhotoLibraryUsageDescription, NSPhotoLibraryAddUsageDescription
Reminders NSRemindersUsageDescription, NSRemindersFullAccessUsageDescription
Siri NSSiriUsageDescription
Speech Recognizer NSSpeechRecognitionUsageDescription
Tracking NSUserTrackingUsageDescription

Installation


Ready to use on iOS 11+. Supports iOS, tvOS. Working with UIKit and SwiftUI.

Swift Package Manager

In Xcode go to Project -> Your Project Name -> Package Dependencies -> Tap Plus. Insert url:

https://github.com/sparrowcode/PermissionsKit

Next, choose the permissions that you need. But don’t add all of them, because apple will reject app. Or adding it to the dependencies of your Package.swift:

dependencies: [
.package(url: “https://github.com/sparrowcode/PermissionsKit”, .upToNextMajor(from: “10.0.1”))
]

and choose valid targets.

CocoaPods:

pod ‘PermissionsKit/NotificationPermission’, :git => ‘https://github.com/sparrowcode/PermissionsKit’

Due to Apple’s new policy regarding permission access you need to specifically define what kind of permissions you want to access using subspecs.

pod ‘PermissionsKit/CameraPermission’, :git => ‘https://github.com/sparrowcode/PermissionsKit’
pod ‘PermissionsKit/ContactsPermission’, :git => ‘https://github.com/sparrowcode/PermissionsKit’
pod ‘PermissionsKit/CalendarPermission’, :git => ‘https://github.com/sparrowcode/PermissionsKit’
pod ‘PermissionsKit/PhotoLibraryPermission’, :git => ‘https://github.com/sparrowcode/PermissionsKit’
pod ‘PermissionsKit/NotificationPermission’, :git => ‘https://github.com/sparrowcode/PermissionsKit’
pod ‘PermissionsKit/MicrophonePermission’, :git => ‘https://github.com/sparrowcode/PermissionsKit’
pod ‘PermissionsKit/RemindersPermission’, :git => ‘https://github.com/sparrowcode/PermissionsKit’
pod ‘PermissionsKit/SpeechRecognizerPermission’, :git => ‘https://github.com/sparrowcode/PermissionsKit’
pod ‘PermissionsKit/LocationWhenInUsePermission’, :git => ‘https://github.com/sparrowcode/PermissionsKit’
pod ‘PermissionsKit/LocationAlwaysPermission’, :git => ‘https://github.com/sparrowcode/PermissionsKit’
pod ‘PermissionsKit/MotionPermission’, :git => ‘https://github.com/sparrowcode/PermissionsKit’
pod ‘PermissionsKit/MediaLibraryPermission’, :git => ‘https://github.com/sparrowcode/PermissionsKit’
pod ‘PermissionsKit/BluetoothPermission’, :git => ‘https://github.com/sparrowcode/PermissionsKit’
pod ‘PermissionsKit/TrackingPermission’, :git => ‘https://github.com/sparrowcode/PermissionsKit’
pod ‘PermissionsKit/FaceIDPermission’, :git => ‘https://github.com/sparrowcode/PermissionsKit’
pod ‘PermissionsKit/SiriPermission’, :git => ‘https://github.com/sparrowcode/PermissionsKit’
pod ‘PermissionsKit/HealthPermission’, :git => ‘https://github.com/sparrowcode/PermissionsKit’

Why Modules


If put all code to one package and compile it, Apple Review Team will see a lot of calls to permissions API and ask you provide reason why you really need it permissions. Modules allow compile only really using code parts. Just select only which you need.

Warning

Import only the permissions you really need.

Request Permission


import PermissionsKit
import NotificationPermission

Permission.notification.request {

}

Get Status Permission


import PermissionsKit
import NotificationPermission

let authorized = Permission.notification.authorized

Warning

For FaceID permission no way detect if request .authorized or .notDetermined accurate. Status .denied detect well. For now for both states return .notDetermined.

Keys in Info. plist


You need to add some strings to the Info.plist file with descriptions per Apple’s requirements. You can get a plist of keys for permissions as follows:

let key = Permission.bluetooth.usageDescriptionKey

Note

Do not use the description as the name of the key. Xcode can’t build this.

Localisation

If you use xliff localization export, keys will be create automatically. If you prefer do the localization file manually, you need to create InfoPlist.strings, select languages on the right side menu and add keys as keys in plist-file. See:

“NSCameraUsageDescription” = “Here description of usage camera”;

Apps Using


           

If you use a PermissionsKit, add your app via Pull Request.

GitHub


View Github

#calendar #camera #dialog #interface #ios #location #notification #permissionkit #permissions #photogallery #reminder #request #scope #sparrow #sppermissions #ui #wizard #xcode
YOU MIGHT ALSO LIKE...
CameraBackground

Features Both front and back camera supported. Flash modes: auto, on, off. Countdown timer. Tap to focus. Pinch to zoom. Usage  

DKCamera

Description A light weight & simple & easy camera for iOS by Swift. It uses CoreMotion framework to detect device orientation, so ...

HorizonSDK-iOS

Horizon SDK is a state of the art real-time video recording / photo shooting iOS library. Some of the features ...

LLSimpleCamera

LLSimpleCamera: A simple customizable camera - video recorder control LLSimpleCamera is a library for creating a customized camera - video ...

RSBarcodes_Swift

RSBarcodes allows you to read 1D and 2D barcodes using the metadata scanning capabilities introduced with iOS 7 and generate ...