A unified API to ask for permissions on iOS

Overview

PAPermissions

PAPermissions is a fully customizable and ready-to-run library to handle permissions through a ViewController

Right now it supports out of the box permissions for:

  • Address Book
  • Bluetooth
  • Calendar
  • Camera
  • Contacts
  • Events
  • Location
  • Microphone
  • Motion Fitness
  • Notifications
  • Reminders
  • Custom

Compatibility

PAPermissions requires iOS8+, compatible with both Swift 4 and Objective-C based projects

If you are looking for the Swift 2 version of it, please check out the legacy branch If you are looking for the Swift 3 version of it, please check out the legacy branch

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects.

To integrate PAPermissions into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'PAPermissions'

Then, run the following command:

$ pod install

Manual Installation

Just copy the PAPermissions folder in your project

Run the Example

Clone the repo, cd into Example:

$ pod install

Or open the project (the blue icon) and copy the PAPermissions folder inside.

Screenshots

It can be used with a plain background color

Or with a background image

How it works

Create a new UIViewController, inherit from PAPermissionsViewController and write:

	let microphoneCheck = PAMicrophonePermissionsCheck()
	let cameraCheck = PACameraPermissionsCheck()

	override func viewDidLoad() {
		super.viewDidLoad()

		//Custom settings
		self.locationCheck.requestAlwaysAuthorization = true


		let permissions = [
	          PAPermissionsItem.itemForType(.microphone, reason: "Required to hear your beautiful voice")!,
					  PAPermissionsItem.itemForType(.camera, reason: "Required to shoot awesome photos")!]

		let handlers = [
						PAPermissionsType.microphone.rawValue: self.microphoneCheck,
						PAPermissionsType.camera.rawValue: self.cameraCheck]
		self.setupData(permissions, handlers: handlers)

		self.titleText = "My Awesome App"
		self.detailsText = "Please enable the following"
	}

That's it!

Anyway you no need to import everything, just remove the unnecessary "check" classes and keep the ones you want to use, you will find them in "Checks" folder.

Contacts

We would love to know if you are using PAPermissions in your app, send an email to [email protected]

Comments
  • error: Segmentation fault: 11

    error: Segmentation fault: 11

    Not working with xcode 12.

    1. While evaluating request SILGenWholeModuleRequest(SIL Generation for module AES__El__Salvador)
    2. While emitting SIL for 'setupUI()' (at /Users/willygonzalez/Documents/iOS Projects/AESApp/AESApp/Helpers/PAPermissions/Classes/PAPermissionsTableViewCell.swift:63:5)
    3. While silgen emitFunction SIL function "@$s17AES__El__Salvador26PAPermissionsTableViewCellC7setupUIyyF". for 'setupUI()' (at /Users/willygonzalez/Documents/iOS Projects/AESApp/AESApp/Helpers/PAPermissions/Classes/PAPermissionsTableViewCell.swift:63:5)

    error: Segmentation fault: 11

    opened by AlexGZC 8
  • Push notification

    Push notification

    So, my app uses PAPermissions to get all the approvals. If I use PAPermission's notifications settings, the didRegisterForRemoteNotificationsWithDeviceToken in AppDelegate is not called. It is getting called with regular Push notification setup.

    Is there any other way to call the didRegisterForRemoteNotificationsWithDeviceToken from PAPermissions after the user allow? Or am I missing something that need to be implemented?

    Thanks for any help.

    opened by AnnieNinaJoyceV 5
  • Cannot enable declined permissions.

    Cannot enable declined permissions.

    When you have declined one of the permission Calendar, Motion, Photo or Notifications then you can't enable them anymore from the app. The other permissions will go to the settings screen like it should.

    opened by evermeer 3
  • Use of private APIs

    Use of private APIs

    App will sometimes get rejected when using the PAPermissions library because of the use of prefs:root=

    Your app uses the "prefs:root=" non-public URL scheme, which is a private entity. The use of non-public APIs is not permitted on the App Store because it can lead to a poor user experience should these APIs change.

    opened by engine-turning 2
  • Properties of PIPermissionsTableViewCell are unnecessarily weak

    Properties of PIPermissionsTableViewCell are unnecessarily weak

    In PAPermissionsTableViewCell, you have the following properties declared as weak:

    weak var iconImageView: UIImageView!
    weak var titleLabel: UILabel!
    weak var detailsLabel: UILabel!
    	
    weak var permission: PAPermissionsItem!
    	
    fileprivate weak var rightDetailsContainer: UIView!
    fileprivate weak var enableButton: UIButton!
    fileprivate weak var checkingIndicator: UIActivityIndicatorView!
    

    There is no circular reference from any of those properties back to PAPermissionsTableViewCell, so those should be regular / strong references. Otherwise, you run the risk of your instance of PAPermissionsTableViewCell outliving one of those items and since they are all declared as being implicitly-unwrapped optionals, you'll crash in that scenario.

    opened by chrismcs 2
  • Add CloudKit discoverability permissions

    Add CloudKit discoverability permissions

    For adding CloudKit discoverability permissions you could use this code. You do have to be aware that this is an async call.

            let container = CKContainer.default()
            container.status(forApplicationPermission: CKApplicationPermissions.userDiscoverability, completionHandler: { applicationPermissionStatus, error in
                     // handle applicationPermissionStatus for statuses like
                     // CKApplicationPermissionStatus.Granted, .Denied, .CouldNotComplete, .InitialState
            })
    
    
            let container = CKContainer.default()
            container.accountStatus(completionHandler: {status, error in
                switch status {
                case .available, .restricted:
                    container.requestApplicationPermission(CKApplicationPermissions.userDiscoverability,  completionHandler: { applicationPermissionStatus, error in
                              // handle applicationPermissionStatus for statuses like CKApplicationPermissionStatus.Granted, .Denied, .CouldNotComplete, .InitialState
                    })
                case .couldNotDetermine, .noAccount: break
                    // Ask user to login to iCloud
                }
            })
    
    opened by evermeer 2
  • Removed implicit and forced unwrapping

    Removed implicit and forced unwrapping

    This project does a lot of implicit and forced unwrapping of vars. That's generally discouraged in Swift since you lose the protection of explicitly handling optionality.

    Also - several vars were declared as weak and were also being force-unwrapped. This semantically doesn't make sense because weak vars, by definition, aren't retained and therefore must be optional. Swift should have probably always thrown an error on this - but as of Swift 5.3 in Xcode 12 Beta, force-unwrapping a weak var will no longer compile (it crashes the compiler). This PR fixes that.

    opened by chrismcs 1
  • Add media-library support

    Add media-library support

    Hello Pasquale,

    thanks for your fine library. I have added support for Media Library permission (done already last year) and want to suggest to add this to your repo, so that we are in sync for the future. The code is tested and running fine. Thanks,

    opened by TomMajor 1
  • 1) How to check status beforehand, 2) support MediaLibrary, 3) permissions for AppStore

    1) How to check status beforehand, 2) support MediaLibrary, 3) permissions for AppStore

    I want to check a permission status before presenting the CustomPermissionsViewController, in case the permission is already ok. How would I do that? In Example Project/ViewController.swift, I tried let calendarCheck = PACalendarPermissionsCheck() print("\(calendarCheck.status)") but it always returns "checking".

    Also I want to add MediaLibrary support. Which check class would you recommend to use as an template for that?

    If I delete the unused check classes in my project, will this prevent the issue "Too many permissions for AppStore", please see https://github.com/nickoneill/PermissionScope/issues/194 I used PermissionScope in the past, but looking for a new solution as PermissionScope is not maintained anymore.

    Thank you very much.

    opened by TomMajor 1
  • Shared is not Available

    Shared is not Available

    Anyone have any idea on why I would get these errors?

    'shared' is unavailable: Use view controller based solutions where appropriate instead.
    
    'openURL' is unavailable
    
    opened by indivisable 1
  • Little Bug

    Little Bug

    Hi,

    A little bug with Blur...

    Replace this 'return self._blurEffectView as! UIVisualEffectView' by 'return self._blurEffectView as? UIVisualEffectView' line 144 in PaPermissionsView.swift

    opened by Droppix 1
  • Fix authorization status button refresh after camera permission activ…

    Fix authorization status button refresh after camera permission activ…

    Hi,

    I've found a little bug when user accept camera permission, the status button was not refreshing because the updateStatus method isn't called in authorization block. Do you agree ?

    opened by aureliendelrue 0
Owner
Pasquale Ambrosini
Full Stack software developer. 🏄‍♂️🛹🍻🚀
Pasquale Ambrosini
Ask permissions on Swift. Available List, Dialog & Native interface. Can check state permission.

SPPermissions About Library for ask permissions. You can check state of permissions, available .authorized, .denied & .notDetermined. Available ready-

Ivan Vorobei 5.1k Dec 30, 2022
Cluster's reusable pre-permissions utility that lets developers ask the users on their own dialog for photos or contacts access, before making the system-based request.

Cluster's reusable pre-permissions utility that lets developers ask the users on their own dialog for photos or contacts access, before making the system-based request. This is based on the Medium post by Cluster describing the different ways to ask for iOS permissions (https://medium.com/p/96fa4eb54f2c).

Riz 1.2k Sep 29, 2022
A polite and unified way of asking for permission on iOS

ISHPermissionKit ISHPermissionKit provides a polite and unified way of asking for permission on iOS. It also provides UI to explain the permission req

iosphere GmbH 619 Nov 3, 2022
A set of SwiftUI dynamic property wrappers that provide a more familiar API for accessing the Contacts framework. (iOS, watchOS, macOS)

Connections Also available as a part of my SwiftUI+ Collection – just add it to Xcode 13+ A set of SwiftUI dynamic property wrappers that provide a mo

SwiftUI+ 9 Oct 7, 2022
AREK is a clean and easy way to request any kind of iOS permission (with some nifty features 🤖)

AREK is a clean and easy to use wrapper over any kind of iOS permission written in Swift. Why AREK could help you building a better app is well descri

Ennio Masi 961 Dec 20, 2022
A visual permission manager for iOS

VWWPermissionKit We've all been there. You get started on your latest and greatest app when you have to add logic to prompt the user for permissions b

Zakk Hoyt 144 Feb 24, 2022
A unified API to ask for permissions on iOS

PAPermissions PAPermissions is a fully customizable and ready-to-run library to handle permissions through a ViewController Right now it supports out

Pasquale Ambrosini 694 Oct 17, 2022
The "Ask Me" is simple iOS application which shows answer on the screen everytime when the user press the ask button

The "Ask Me" is simple iOS application which shows answer on the screen everytime when the user press the ask button. This application is build and design by Chetan Parate using Xcode and Swift.

Chetan Parate 0 Oct 27, 2021
An iOS pre-permissions utility that lets developers ask users on their own dialog for calendar, contacts, location, photos, reminders, twitter, push notifications and more, before making the system-based permission request.

An iOS pre-permissions utility that lets developers ask users on their own dialog for calendar, contacts, location, photos, reminders, twitter, push notifications and more, before making the system-based permission request.

Joe L 420 Dec 22, 2022
Ask permissions on Swift. Available List, Dialog & Native interface. Can check state permission.

SPPermissions About Library for ask permissions. You can check state of permissions, available .authorized, .denied & .notDetermined. Available ready-

Ivan Vorobei 5.1k Dec 30, 2022
Cluster's reusable pre-permissions utility that lets developers ask the users on their own dialog for photos or contacts access, before making the system-based request.

Cluster's reusable pre-permissions utility that lets developers ask the users on their own dialog for photos or contacts access, before making the system-based request. This is based on the Medium post by Cluster describing the different ways to ask for iOS permissions (https://medium.com/p/96fa4eb54f2c).

Riz 1.2k Sep 29, 2022
Unified API Library for: Cloud Storage, Social Log-In, Social Interaction, Payment, Email, SMS, POIs, Video & Messaging.

Unified API Library for: Cloud Storage, Social Log-In, Social Interaction, Payment, Email, SMS, POIs, Video & Messaging. Included services are Dropbox, Google Drive, OneDrive, OneDrive for Business, Box, Egnyte, PayPal, Stripe, Google Places, Foursquare, Yelp, YouTube, Vimeo, Twitch, Facebook Messenger, Telegram, Line, Viber, Facebook, GitHub, Google+, LinkedIn, Slack, Twitter, Windows Live, Yahoo, Mailjet, Sendgrid, Twilio, Nexmo, Twizo.

CloudRail 195 Nov 29, 2021
RxSwift bindings for Permissions API in iOS.

RxPermission RxSwift bindings for Permission API that helps you with Permissions in iOS. Installation RxPermission is available through CocoaPods. I c

Luke 230 Dec 27, 2022
A polite and unified way of asking for permission on iOS

ISHPermissionKit ISHPermissionKit provides a polite and unified way of asking for permission on iOS. It also provides UI to explain the permission req

iosphere GmbH 619 Nov 3, 2022
Easy to use cryptographic framework for data protection: secure messaging with forward secrecy and secure data storage. Has unified APIs across 14 platforms.

Themis provides strong, usable cryptography for busy people General purpose cryptographic library for storage and messaging for iOS (Swift, Obj-C), An

Cossack Labs 1.6k Dec 30, 2022
Easy to use cryptographic framework for data protection: secure messaging with forward secrecy and secure data storage. Has unified APIs across 14 platforms.

Themis provides strong, usable cryptography for busy people General purpose cryptographic library for storage and messaging for iOS (Swift, Obj-C), An

Cossack Labs 1.6k Dec 30, 2022
A simple and attractive AlertView to ask permission to your users for Push Notification.

A simple and attractive AlertView **to ask permission to your users for Push Notification.** PRESENTATION Ask permission to user for push notification

Boisney Philippe 37 Mar 23, 2022
Review page interaction - handy and pretty way to ask for review.

RPInteraction Overview Review page interaction - handy and pretty way to ask for review. Inspired by dribbble shot. Requirements iOS8 Installation RPI

Nurdaulet Bolatov 27 Jul 16, 2021
Review page interaction - handy and pretty way to ask for review

RPInteraction Overview Review page interaction - handy and pretty way to ask for review. Inspired by dribbble shot. Requirements iOS8 Installation RPI

Nurdaulet Bolatov 27 Jul 16, 2021
🗣Voice overlay helps you turn your user's voice into text, providing a polished UX while handling for you the necessary permissions

Voice overlay helps you turn your user's voice into text, providing a polished UX while handling for you the necessary permissions. It uses i

Algolia 490 Dec 19, 2022