Make permission request easier.

Related tags

Permissions Proposer
Overview

Proposer

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

Requirements

Swift 4.2, iOS 9.0

(Swift 3, use version 1.1.0)

Example

Only one single API:

proposeToAccess(_:agreed:rejected:)

In real world:

import Proposer
@IBAction func choosePhoto() {
    let photos: PrivateResource = .photos
    let propose: Propose = {
        proposeToAccess(photos, agreed: {
            print("I can access Photos. :]\n")
            if UIImagePickerController.isSourceTypeAvailable(.savedPhotosAlbum) {
                let imagePicker = UIImagePickerController()
                imagePicker.sourceType = .savedPhotosAlbum
                self.present(imagePicker, animated: true, completion: nil)
            }
        }, rejected: {
            self.alertNoPermissionToAccess(photos)
        })
    }
    showProposeMessageIfNeedFor(photos, andTryPropose: propose)
}

When you want to get user's location, thanks to Swift's enum, you can even choose the usage mode:

@IBAction func shareLocation() {
    let location: PrivateResource = .location(.whenInUse)
    let propose: Propose = {
        proposeToAccess(location, agreed: {
            print("I can access Location. :]\n")
        }, rejected: {
            self.alertNoPermissionToAccess(location)
        })
    }
    showProposeMessageIfNeedFor(location, andTryPropose: propose)
}

Depending on your needs, you must add a NSLocationWhenInUseUsageDescription or NSLocationAlwaysUsageDescription to your Info.plist

See the demo for more information.

I recommend you add a UIViewController+Proposer.swift file (like the demo) for show localized alert before the first proposal or when propose failed.

Installation

Feel free to drag Proposer.swift to your iOS Project. But it's recommended to use Carthage (or CocoaPods).

Carthage

github "nixzhu/Proposer"

CocoaPods

pod 'Proposer'

Contact

NIX @nixzhu

License

Proposer is available under the MIT license. See the LICENSE file for more info.

Comments
  • Remove unneeded elements from Podfile

    Remove unneeded elements from Podfile

    source 'https://github.com/CocoaPods/Specs.git' shouldn't be needed, it's the default one.

    use_frameworks! frameworks are auto-used if there's a Swift pod.

    opened by 3lvis 3
  • iOS 8 crash Contacts Library not loaded

    iOS 8 crash Contacts Library not loaded

    I have a crash in iOS 8, beacuse the library use Contacts library, but Contacts library is available in iOS 9.0

    dyld: Library not loaded: /System/Library/PrivateFrameworks/ContactsPersistence.framework/Versions/A/ContactsPersistence Referenced from: /System/Library/Frameworks/Contacts.framework/Contacts Reason: no suitable image found. Did find: /System/Library/PrivateFrameworks/ContactsPersistence.framework/Versions/A/ContactsPersistence: mach-o, but not built for iOS simulator

    opened by isandboy 2
  • alertMessages not found

    alertMessages not found

    Hi, cant find these methods

            self.alertNoPermissionToAccess(photos) 
           showProposeMessageIfNeedFor(photos, andTryPropose: propose)
    

    am I supposed to write them myself ?

    opened by Mahan3340 1
  • Doesn't ask permission for Contacts

    Doesn't ask permission for Contacts

    Hi, Thank you for this wonderful library. I however am having some trouble asking for permissions for Contacts. The thing is, when I use this following code, it just assumes that the callback is for the agreed action, and goes into case: .Authorized in private method proposeToAccessContacts in Proposer.swift. It doesn't even take any interaction from user and goes into authorized. Please help.

    let contacts: PrivateResource = .Contacts

    proposeToAccess(contacts, agreed: { self.delegate?.successAction(self) //Always successful without any user interaction }, rejected: { self.delegate?.failureAction(self) })

    opened by mohsinka 1
  • Support to UNNotificationSettings

    Support to UNNotificationSettings

    As UIUserNotificationSettings will be deprecated to iOS 11, do you have plans on also use UNNotificationSettings with @available in order to support from iOS 8 to 11?

    https://developer.apple.com/documentation/usernotifications/unusernotificationcenter https://developer.apple.com/documentation/uikit/uiusernotificationsettings

    opened by GabrielAraujo 0
  • make Swift 2.0

    make Swift 2.0

    Create a new branch swift_2.0 I will make a PR to that branch. This way wi will keep both version working. I will make a separate PR for each feature #4 Relater to the RP

    opened by kostiakoval 0
  • Release 1.2.1 breaks build with Swift 4.1

    Release 1.2.1 breaks build with Swift 4.1

    Last version cannot be compiled with Swift 4.1 (Xcode 9.4.1).

    Proposer.swift:38:69: error: binary operator '==' cannot be applied to operands of type '() -> AVAudioSessionRecordPermission' and '_'
                return AVAudioSession.sharedInstance().recordPermission == .undetermined
    

    Maybe it would warrant a major version change?

    opened by PetrPrazak 1
Owner
null
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
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 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
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
Request the Location Services via a 3D 360° flyover MKMapView 🗺

STLocationRequest STLocationRequest is a simple and elegant way to request the users location services at the very first time. The STLocationRequestCo

Sven Tiigi 640 Dec 6, 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
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
This app is a sample app that recognizes specific voice commands such as "make it red", "make it blue", "make it green", and "make it black" and change the background color of the view in the frame.

VoiceOperationSample This app is a sample app that recognizes specific voice commands such as "make it red", "make it blue", "make it green", and "mak

Takuya Aso 3 Dec 3, 2021
This package is meant to make http request of an easy way inspiren in the architecture of Moya package

NetworkAgent This package is meant to make http request of an easy way inspiren in the architecture of Moya package. This package is 100% free of depe

Angel Rada 19 Sep 8, 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
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
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
SugarRecord is a persistence wrapper designed to make working with persistence solutions like CoreData in a much easier way.

What is SugarRecord? SugarRecord is a persistence wrapper designed to make working with persistence solutions like CoreData in a much easier way. Than

Modo 2.1k Dec 29, 2022
NVDate is an extension of NSDate class (Swift4), created to make date and time manipulation easier.

NVDate is an extension of NSDate class (Swift4), created to make date and time manipulation easier. NVDate is testable and robust, we wrote intensive test to make sure everything is safe.

Noval Agung Prayogo 177 Oct 5, 2022
KDEDateLabel is an UILabel subclass that updates itself to make time ago's format easier.

KDEDateLabel KDEDateLabel is an UILabel subclass that saves you from refreshing it when using 'time ago' format. Installation You have multiple choice

Kevin Delannoy 117 May 16, 2022
Blueprints is a collection of flow layouts that is meant to make your life easier when working with collection view flow layouts.

Blueprints is a collection of flow layouts that is meant to make your life easier when working with collection view flow layouts. It comes

Christoffer Winterkvist 982 Dec 7, 2022