A visual permission manager for iOS

Overview

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 before your app can access any of these resources. Many users will deny access unless you convince them that your app can be trusted. If they deny access, you must then try to convince them to go to iOS Privacy Settings, find your app, enable those permissions, switch back to your app, read permissions again, etc...

Another difficulty: The permissions from Apple's frameworks use many different classes, and they don't share the same data type regarding status. PhotoKit uses PHAuthorizationStatus, EventKit uses EKAuthorizationStatus, Core Location uses CLAuthorizationStatus, and so on.

VWWPermissionKit solves these problems by presenting your user with an easy to read list of permissions that they need to approve before iOS prompts them. This makes it simple for a user to understand why they should approve permissions. Each button triggers an iOS prompt one at a time all from one central view. VWWPermissionKit will also automatically detect changes if the user changes a setting in your app's privacy settings.

How to use VWWPermissionKit

Although written in Obj-C, it is easy to use VWWPermissionKit from both Obj-C and Swift. An example project is included for each language.

To get started, first import VWWPermissionKit to your file if using Obj-C or your Bridging Header if using Swift.

#import "VWWPermissionKit.h"

Next create an array of VWWPermission types and display the permissions window. Once that all the permissions are authorized the form is dimissed and the resultsBlock is called. You can inspect each permission here.

###ObjC

VWWCameraPermission *camera = [VWWCameraPermission permissionWithLabelText:@"This app lets your record videos, so we need to access your camera"];
VWWPhotosPermission *photos = [VWWPhotosPermission permissionWithLabelText:@"We can save recorded videos to your Photos library."];
VWWCoreLocationAlwaysPermission *locationAlways = [VWWCoreLocationAlwaysPermission permissionWithLabelText:@"For calculating your heading, altitude, speed, distance home, etc... This is a bunch of nonsense text to show that labels will grow with the size of the defined text. This text that you are reading right now. Period."];


NSArray *permissions = @[camera, locationAlways, photos];

[VWWPermissionsManager optionPermissions:permissions
                                   title:@"Welcome to the VWWPermissionKitExample app. Our app uses many of your device's sensors. We'll help you set up some permissions, then get started."
                      fromViewController:self
                            resultsBlock:^(NSArray *permissions) {
                                [permissions enumerateObjectsUsingBlock:^(VWWPermission *permission, NSUInteger idx, BOOL *stop) {
                                    NSLog(@"%@ - %@", permission.type, [permission stringForStatus]);
                                }];
                            }];

###Swift

let photos = VWWPhotosPermission.permissionWithLabelText("In order to write to your Camera Roll")
let camera = VWWCameraPermission.permissionWithLabelText("In order to access your camera to record video.")
let coreLocationAlways = VWWCoreLocationAlwaysPermission.permissionWithLabelText("To calculate your heading, altitude, speed, distance home, etc...")
let permissions = [photos, camera, coreLocationAlways]

VWWPermissionsManager.requirePermissions(permissions, title: "Swift Test", fromViewController: self) { (permissions: [AnyObject]!) -> Void in
    print("permission")
}

Alternatively, there is a permissions readonly function which shows no GUI. It simply reads each permission type and returns with the benefit that all permissions share the same datatype.

###ObjC

[VWWPermissionsManager readPermissions:permissions resultsBlock:^(NSArray *permissions) {
    [permissions enumerateObjectsUsingBlock:^(VWWPermission *permission, NSUInteger idx, BOOL *stop) {
        NSLog(@"%@ - %@", permission.type, [permission stringForStatus]);
    }];
}];

###Swift

VWWPermissionsManager.readPermissions(permissions) { (permissions:[AnyObject]!) -> Void in
    for (_, permission) in permissions.enumerate(){
        if permission.status != VWWPermissionStatusAuthorized {
            // User didn't authorize this one
        }
    }
}

Tapping on the "Privacy" button will navigate the user to your iOS app's privacy settings where they can change permissions. The user is also navigated here if they tap a red button. Once the user switches back to your app, the permissions are re-read and the screen is updated.

Sample images

Adding the cocoa framework to your iOS project

To add VWWPermissionKit to your application, drag the VWWPermissionKit.xcodeproj project file into your application's project. XCode will add the VWWPermissionKit project and source files.

Next tell XCode to embed VWWPermissionKit into your app. Go to your app's target build settings and choose the "General" tab. Under the "Embedded Binaries" grouping, add VWWPermissionKit. XCode should automatically add link references for you.

Finally you'll need to tell XCode where to find the proper headers. Go to the Build Settings tab. Type "header " in the search bar. The go to the section "Search Paths" and add an the VWWPermissionKit file path to "Header Search Paths" (recursive: YES)

CocoaPods integration

YSK

To import this framework with CocoaPods just add this line to your podfile

pod 'VWWPermissionKit', '~> 1.3.0'

Functional Permission classes

  • VWWAssetLibraryPermission: AssetsLibrary
  • VWWCameraPermission: AVFoundation and UIImagePickerController
  • VWWCalendarsPermission: EventKit framework
  • VWWCoreLocationAlwaysPermission: CoreLocation framework
  • VWWCoreLocationWhenInUsePermission: CoreLocatoin framework
  • VWWCoreMotionPermission: CoreMotion framework
  • VWWMicrophonePermission: AVFoundation framework
  • VWWNotificationsPermission: UIApplication (remote, user, and local)
  • VWWRemindersPermission: EventKit framework
  • VWWPhotosPermission: Photos framework

In-Development Permission classes

  • VWWAccountsPermission: Accounts framework
  • VWWBluetoothPermission: CoreBluetooth framework
  • VWWCloudKitPermission: CloudKit framework
  • VWWHealthPermission: HealthKit framework
  • VWWHomePermission: HomeKit framework

YSK

  • Not all permissions types are supported in the iOS Simulator
  • iOS 9 (beta) does not detect changes to permission status from iOS Privacy Settings without restarting the app. I expect this will be fixed in the near future.

What's new in this version?

  • Removed ALAssetsLibrary as it's deperecated (Use the new Photos API)
  • Replaced AddressBook API with Contacts new Contacts API
  • Support for CoreMotion
  • Updated UI for a cleaner look
  • Adherence to +appearance protocol
  • Warns about missing entries for your Info.plist
  • Unsupported services are displayed as such
  • Support for dynamic font sizes
Comments
  • Detect exclusion of Info.plist entries

    Detect exclusion of Info.plist entries

    For example. in coreLocation if the previous and new status are both Not determined, then it's likely that the app dev forgot to add NSLocationAlwaysUsageDescription | NSLocationWhenInUseUsageDescription

    duplicate 
    opened by zakkhoyt 1
  • 1.1 Release

    1.1 Release

    Ensure that obj-c sample app works as intended Ensure that swift sample app works as intended Remove personal xcproj tokens so that anyone can checkout and build

    Update README

    • make gif
    • What's new
    • cocoapods section

    Update podspec Test a checkout Submit pod

    Merge to Master

    Inform parties of the change

    opened by zakkhoyt 0
  • Add permission state NotSupported

    Add permission state NotSupported

    Some devices may not be able to use said services. For example +[CMMotionActivityManager isActivityAvailable];

    Add a new enum to the permissions and represent it in the GUI

    enhancement 
    opened by zakkhoyt 0
  • Hide default system Permission popup's

    Hide default system Permission popup's

    Hello sir, I have seen this Demo app and I want to implement this my project. My project is in swift 2. I have implemented this code successfully in my app, but the problem is I have added permission in info.plist. So, when I launch the app the app, It automatically show the default system popup's. I just want to hide the default system popup's and show "VWWPermissionKit" Permission popup's.Any Suggestion regarding this is appreciated.

    opened by Gurmeetkaur5949 1
  • Dealloc Never Called

    Dealloc Never Called

    Hello,

    Great work on the project. I am implementing this in a Obj-C project. The issue I have is that dealloc is never called.

    For example, I have the following workflow:

    • Read specific permissions
    • Display a view controller to enable permissions (based on the first step, whichever ones are not enabled)
    • Then they can close the view controller

    The issue I have is that the Notifications are being observed twice, once from the read init and then again from the optional permissions init.

    The dealloc obviously removes these, but it is never called. When should it be called in an ARC project? When should the manager be released, I think it hangs around because of the notifications.

    Thanks

    opened by StuartMorris0 2
Owner
Zakk Hoyt
Zakk Hoyt
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
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
Make permission request easier.

Proposer Proposer provides a single API to request permission for access Camera, Photos, Microphone, Contacts, Reminders, Calendar, Location or Notifi

null 855 Nov 3, 2022
A unified API to ask for permissions on iOS

Permission exposes a unified API to request permissions on iOS. Usage • Example • Installation • License Usage Permission Permission.swift PermissionS

Damien 2.9k Dec 27, 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
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 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
Permission Util for iOS (feat.RxSwift)

EzRxPermission Example To run the example project, clone the repo, and run pod install from the Example directory first. Requirements Installation EzR

Yunjae-Na 4 Jun 30, 2022
Simplifies iOS user permission requests (location, push notifications, camera, contacts, calendar, photos, etc).

ICanHas Swift 4 library that simplifies iOS user permission requests (push notifications, location, camera, photo library, contacts, calendar). Instal

Adolfo Rodriguez 91 Jun 2, 2022
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
Swift Package for fetching approximate user location without asking for their permission 👺 .

Earendil Swift Package for fetching approximate user location without asking for their permission ?? . Get their country, subregion or continent with

Przemysław Jabłoński 4 Sep 3, 2021
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
Make permission request easier.

Proposer Proposer provides a single API to request permission for access Camera, Photos, Microphone, Contacts, Reminders, Calendar, Location or Notifi

null 855 Nov 3, 2022
Visual designing library for iOS & OSX

ProcessingKit ProcessingKit is a Visual designing library for iOS & OSX. ProcessingKit written in Swift ?? and you can write like processing. Demo Dem

Atsuya Sato 333 Nov 12, 2022
Visual Positioning System SDK iOS

VPS SDK (iOS) This is Visual Positioning System SDK for Native iOS apps. Main features are: High-precision global user position localization for your

SberDevices 6 Nov 15, 2022
A custom visual calendar for iOS 8+ written in Swift (>= 4.0).

Overview Screenshots GIF Demo Installation Usage Architecture Version matrix Advanced API For contributors Screenshots GIF Demo Installation CocoaPods

null 3.5k Dec 24, 2022
A visual developer tool for inspecting your iOS application data structures.

Tree Dump Debugger A visual developer tool for inspecting your iOS application data structures. Features Inspect any data structure with only one line

null 8 Nov 2, 2022
📰 Consistent & accessible visual styling on iOS with support for Dynamic Type.

TypographyKit makes it easy to define typography styles and colour palettes in your iOS app helping you achieve visual consistency in your design as w

Ross Butler 162 Dec 27, 2022