Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sparrowcode/PermissionsKit
Universal API for request permission and get its statuses.
https://github.com/sparrowcode/PermissionsKit
calendar camera dialog interface ios location notification permission permissionkit permissions photo-gallery reminder request scope sparrow sppermissions ui wizard xcode
Last synced: 3 months ago
JSON representation
Universal API for request permission and get its statuses.
- Host: GitHub
- URL: https://github.com/sparrowcode/PermissionsKit
- Owner: sparrowcode
- License: mit
- Created: 2017-02-16T17:49:57.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2023-12-14T14:53:38.000Z (11 months ago)
- Last Synced: 2024-05-01T09:41:50.092Z (6 months ago)
- Topics: calendar, camera, dialog, interface, ios, location, notification, permission, permissionkit, permissions, photo-gallery, reminder, request, scope, sparrow, sppermissions, ui, wizard, xcode
- Language: Swift
- Homepage: https://sparrowcode.io/frameworks
- Size: 107 MB
- Stars: 5,534
- Watchers: 93
- Forks: 446
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-ios - SPPermissions - Ask permissions on Swift. Available List, Dialog & Native interface. Can check state permission. (Permissions / Other Parsing)
README
# PermissionsKit
Universal API for request permission and get its statuses — available `.authorized`, `.denied` & `.notDetermined`.
### iOS Dev Community
## Navigate
- [Permissions](#permissions)
- [Installation](#installation)
- [Swift Package Manager](#swift-package-manager)
- [CocoaPods](#cocoapods)
- [Why Modules](#why-modules)
- [Usage](#request-permission)
- [Request Permission](#request-permission)
- [Get Status Permission](#get-status-permission)
- [Keys in Info.plist](#keys-in-infoplist)
- [Localisations](#localisation)
- [Apps Using](#apps-using)### 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 12+. Supports iOS, macOS, visionOS, tvOS & watchOS. 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`:```swift
dependencies: [
.package(url: "https://github.com/sparrowcode/PermissionsKit", .upToNextMajor(from: "11.0.0"))
]
```and choose valid targets.
### CocoaPods:
This is an outdated way. I advise you to use [SPM](#swift-package-manager). However, I will continue to support Cocoapods for some time.
Cocoapods Installation
[CocoaPods](https://cocoapods.org) is a dependency manager. For usage and installation instructions, visit their website. To integrate using CocoaPods, specify it in your `Podfile`:
```ruby
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.
```ruby
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/LocationPermission', :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 you put all your code into one package and compile it, the Apple Review Team will see a lot of calls to the permissions API. Most likely, they will ask you to provide a valid reason for why you really need those permissions. Using modules allows you to compile only the parts of the code that are actually in use. Just select only what you need.
> [!WARNING]
> Import only the permissions you really need.## Request Permission
```swift
import PermissionsKit
import NotificationPermissionPermission.notification.request {
}
```## Get Status Permission
```swift
import PermissionsKit
import NotificationPermissionlet 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:
```swift
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.