Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Universal API for request permission and get its statuses.

License

NotificationsYou must be signed in to change notification settings

sparrowcode/PermissionsKit

Repository files navigation

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

iOS Dev Community

Navigate

Permissions

IconPermissionKey forInfo.plistGet StatusMake Request
BluetoothNSBluetoothAlwaysUsageDescription, NSBluetoothPeripheralUsageDescription
CalendarNSCalendarsUsageDescription, NSCalendarsFullAccessUsageDescription, NSCalendarsWriteOnlyAccessUsageDescription
CameraNSCameraUsageDescription
ContactsNSContactsUsageDescription
FaceIDNSFaceIDUsageDescription☑️
HealthNSHealthUpdateUsageDescription, NSHealthShareUsageDescription
LocationNSLocationAlwaysAndWhenInUseUsageDescription NSLocationWhenInUseUsageDescription
Media LibraryNSAppleMusicUsageDescription
MicrophoneNSMicrophoneUsageDescription
MotionNSMotionUsageDescription
Notification
Photo LibraryNSPhotoLibraryUsageDescription, NSPhotoLibraryAddUsageDescription
RemindersNSRemindersUsageDescription, NSRemindersFullAccessUsageDescription
SiriNSSiriUsageDescription
Speech RecognizerNSSpeechRecognitionUsageDescription
TrackingNSUserTrackingUsageDescription

Installation

Ready to use on iOS 12+. Supports iOS, macOS, visionOS, tvOS & watchOS. Working withUIKit andSwiftUI.

Swift Package Manager

In Xcode go to Project -> Your Project Name ->Package Dependencies -> TapPlus. 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 thedependencies of yourPackage.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 useSPM. 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 yourPodfile:

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 PermissionsKitimport NotificationPermissionPermissionsKit.Permission.notification([.alert,.badge,.sound]).request{}

Get Status Permission

import PermissionsKitimport NotificationPermissionletauthorized=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 inInfo.plist

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

letkey=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 createInfoPlist.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 aPermissionsKit, add your app via Pull Request.

Sponsor this project

 

Contributors49


[8]ページ先頭

©2009-2025 Movatter.jp