Zurück zum Ranking

sparrowcode/PermissionsKit

Swiftx.com/sparrowcode_ios

Universal API for request permission and get its statuses.

permissionpermissionsiosrequestsparrowlocationnotificationcameraphoto-galleryuidialogxcode
Sterne-Wachstum
Sterne
5.8k
Forks
478
Wochenwachstum
Issues
4
2k4k
Feb. 2017März 2020Mai 2023Juli 2026
README

PermissionsKit

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

iOS Dev Community

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:

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. However, I will continue to support Cocoapods for some time.

Cocoapods Installation

CocoaPods is a dependency manager. For usage and installation instructions, visit their website. To integrate using CocoaPods, specify it in your Podfile:

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/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

import PermissionsKit
import NotificationPermission

PermissionsKit.Permission.notification([.alert, .badge, .sound]).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.

Ähnliche Repositories
Blankj/AndroidUtilCode

:fire: Android developers should collect the following utils(updating).

JavaMavenApache License 2.0androidapp
blankj.com/2016/07/31/android-utils-code/
33.7k10.6k
apache/casbin

Apache Casbin: an authorization library that supports access control models like ACL, RBAC, ABAC.

GoGo ModulesApache License 2.0casbinaccess-control
casbin.apache.org
20.3k1.8k
casbin/casbin

An authorization library that supports access control models like ACL, RBAC, ABAC in Golang: https://discord.gg/S5UjpzGZjN

GoGo ModulesApache License 2.0casbinaccess-control
casbin.org
18.3k1.7k
spatie/laravel-permission

Associate users with roles and permissions

PHPPackagistMIT Licenselaravelphp
spatie.be/docs/laravel-permission
12.9k1.8k
permissions-dispatcher/PermissionsDispatcher

A declarative API to handle Android runtime permissions.

JavaMavenApache License 2.0androidkotlin
github.com/permissions-dispatcher/PermissionsDispatcher
11.2k1.4k
getActivity/XXPermissions

Android Permissions Framework, Adapt to Android 17

JavaMavenApache License 2.0permission-androidpermission
6.8k901
yanzhenjie/AndPermission

:strawberry: Permissions manager for Android platform.

JavaMavenApache License 2.0permissionandroid-permission
yanzhenjie.com/AndPermission
6.6k1.1k
Permify/permify

An open-source authorization as a service inspired by Google Zanzibar, designed to build and manage fine-grained and scalable authorization systems for any application. — Permify is now part of FusionAuth 🎉

GoGo ModulesGNU Affero General Public License v3.0access-controlauthorization
permify.co
5.9k322
zenstackhq/zenstack

Modern data layer for TypeScript apps - type-safe ORM, built-in access control, automatic query services

TypeScriptnpmMIT Licensefullstacknextjs
zenstack.dev
2.9k149
apache/casbin-node-casbin

An authorization library that supports access control models like ACL, RBAC, ABAC in Node.js and Browser

TypeScriptnpmApache License 2.0casbinnodejs
casbin.org
2.9k230
casbin/node-casbin

An authorization library that supports access control models like ACL, RBAC, ABAC in Node.js and Browser

TypeScriptnpmApache License 2.0casbinnodejs
casbin.org
2.7k218
apache/casbin-jcasbin

An authorization library that supports access control models like ACL, RBAC, ABAC in Java

JavaMavenApache License 2.0casbinjava
casbin.org
2.6k491