Giter Club home page Giter Club logo

permissionskit's Introduction

PermissionsKit

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

iOS Dev Community

Navigate

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 11+. Supports iOS, tvOS. 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: "10.0.1"))
]

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/LocationWhenInUsePermission', :git => 'https://github.com/sparrowcode/PermissionsKit'
pod 'PermissionsKit/LocationAlwaysPermission', :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 put all code to one package and compile it, Apple Review Team will see a lot of calls to permissions API and ask you provide reason why you really need it permissions. Modules allow compile only really using code parts. Just select only which you need.

Warning

Import only the permissions you really need.

Request Permission

import PermissionsKit
import NotificationPermission

Permission.notification.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.

permissionskit's People

Contributors

alexanderpuchta avatar angcosmin avatar cozzin avatar damarte avatar dan12411 avatar ddomovoj avatar dlackty avatar duyhungtnn avatar evaanp avatar hengyu avatar ivanvorobei avatar jminutaglio avatar jobinsjohn avatar juanillo62gm avatar matrixsenpai avatar mgt-la avatar mohammad-rahchamani avatar moyoteg avatar neobeppe avatar oggerschummer avatar ostatnicky avatar romanpodymov avatar rsickenberg avatar sagaya avatar semty avatar srujanadicharla avatar strobocop avatar svyatoynick avatar tomkremer avatar utsavdave97 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

permissionskit's Issues

updatePermissionsStyle does not consider

If you have say enable MicroPhone, and Enable Location (whenAppInUse) and you enable the microphone, but reply NO to the request to enable location, then jump to the Settings App and allow it, then jump back to the app

Then the updatePermissionsStyle() function runs via the request earlier made via
NotificationCenter.default.addObserver(self, selector: #selector(self.updatePermissionsStyle), name: NSNotification.Name.UIApplicationDidBecomeActive, object: nil)

But this does not trigger the SPRequestPermissionDialogInteractivePresenter>>actionForControl logic that would run the if allPermissionAllowed {} logic to autoclose the dialog view controller. Rather it just invokes control.setSelectedState(animated: false) for each permission that is true.

The end result is the dialog does not autoclose, nor does the caller's delegate methods viaSPRequestPermissionEventsDelegate get invoked to do any special processing.

notes: perhaps on the app going inactive you'll have to remember state of permissions so you can properly fire delegate methods based on state change found in activation.

Location when in use permission

First off, great library.

I am trying to add permissions for location except I only want "When in use" and not "Always" which this library does. Is it possible to do this with the library already, if not could you add this functionality? Maybe something like .LocationWhenInUse

Customization missing

Hello,
I just start to use your lib and it is very nice, easy to use / configure .

I just have an issue with one customization. I am doing an app mainly in French, and there is one popup I did not manage to change / localize
capture d ecran 2017-05-09 a 11 38 46

I am asking the permission one at a time (when needed) so basically one by one. Is very a way to customize the text based on notification type (not very important and maybe to specific to my case)
edit : I just plug my brain and ... I just have to create 2 datasources.... easy

thanks for you work

Segmentation 11 - YES AGAIN!

Although it's a nice pod, it needs tons of work regarding its pod handling.
When updating pod, I get that I am at version 1.0.0 whereas previous version was 1.0.1!!! When I remove the pod and reinstall it I get segmentation 11 fault when building. I checked the answers to the other closed issues but really no professional solution has been proposed. A guy deletes a swift file from the pod and uses it's code directly. Not a good way. The author just denies to fix this. And no, I won't zip and send you anything from my machine for you to check.
If you fix this, I 'll try this pod again, otherwise I 'll have to use another permission pod from out there...

Regards

Segmentation Fault 11

SPRequestPermission.swift is producing a compilation error on given xcodeproj.
Fresh XCode installation on a NEW machine.

Can't Compile- Segmentation Fault

Hi, thanks for spending the time to create this! It looks great and I'm trying to use this in a project of mine.

Unfortunately, when manually integrating this into my project (Not using CocoaPods), I am getting an error while building the file: SPRequestPermission.swift . I'm also encountering the same error when trying to build your sample project. This is the error I get: "Command failed due to signal: Segmentation fault: 11"

As a reference I am using Xcode 8.2.

I'd greatly appreciate your help resolving this issue... Thanks!

permission button doesn't work for locationWhileInUse

I'm not sure why, all other Permissions work just fine, but not for locatioWhileInUse

I have used this key in my info.list
NSLocationAlwaysAndWhenInUseUsageDescription
I tried all the other three, but same problem

in podFile
platform :ios, '9.0'
target 'weekend' do

use_frameworks!

pod 'Sparrow/Modules/RequestPermission', :git => 'https://github.com/IvanVorobei/Sparrow.git'

xcode 9.3 swift 4.3 iPhone 7 Plus, iOS 11.3

thanks

localized the text ?

Currently we haven't possibility to localized text permission, do you think you can integrate this functionnality soon ?

Xcode 4 compatibility

Hey, so I have updated your git as well as updated my Xcode to version 9. However, when I run my project I receive several errors from sparrow. Wondering if these errors could be fixed.

Xcode 9 / iOS 11

Hi. I was about to use this some app updates that are scheduled to be released in a few weeks. I am reading about issues with Xcode 9/ iOS 11 in both closed issues and open ones with segmentation faults.

I have been using this stand-alone and trying subclassing, but I have not used cocoa pods to put it into my production code base.

Is there being work done to make this transition that we will soon be using? I just do not want to incorporate this great framework if is not close to be ready for Xcode 9, etc.

Add Reminders?

I think this would be another awesome one to have. Thank you for the fantastic project!

Access denied

Reproduce: Presenting SPRequest.Dialog -> Denie access (e.g. for camera) -> you will not see the altert to get directed to settings.

This worked with the last version.

setHeaderBackgroundView Called Twice

SPRequestPermissionDialogInteractivePresenter.swift, around line 58.
The method setHeaderBackgroundView is called twice, from my readings it's not necessary.

App rejected

Got my app rejected due to:
"Push notifications must be optional and must obtain the user's consent to be used within the app."

attachment-2238713732170665354screenshot_0308_095811

In the picture the "Swipe to dismiss" isn´t visible, i don´t know why. So the user can´t get anywhere from here if the user don´t try to drag the popup.

To fix this i suggest that if you the user don´t allow permission the button should turn red with a cross and don´t show the alertview in the picture. That alert should only show when the user press that button again.
And when all permission is answered (allowed or denied) the popup should automatically close.

Does not work with Xcode 9

When I try to build my project,I get a strange error
If the destination is a simulator, the compiler will give this error:Command failed due to signal: Segmentation fault: 11
If the destination is a device in the real world,it will will give Command failed due to signal: Abort trap: 6

didRegisterForRemoteNotificationsWithDeviceToken

When accepting the enable notification .. didRegisterForRemoteNotificationsWithDeviceToken is not being called... I would expect that to be the case? How else would I go about getting the device token after they accepted enabling notifications?

Allow Escalating Location Permissions

If a user upon first launch authorizes .locationWhenInUse, and then later, when taking a certain action, needs to authorize .locationAlways, it shows as denied and that they need to change the settings from iPhone App settings. In fact, it is possible to upgrade from here, in-app, without going to the iPhone App Settings. (:

Distingish button for locationAlways and locationWhenInUse

Hi,
is there a possibility to change the text for button "Enable Location" in case of locationAlways to "Enable Location Always"?
Otherwise users will be confused, because they do not know which of the Location Options are required to grant.

Thanks,
Ghent

Use of unresolved identifier 'SPRequestPermission'

Hi Everyone,
i have this error message under Swift Compiler Error Panel , where is the problem?

HomeViewController.swift:32:9: Use of unresolved identifier 'SPRequestPermission'

    override func viewDidAppear(_ animated: Bool) {        
        SPRequestPermission.dialog.interactive.present(on: self, with: [.camera, .photoLibrary, .notification])
    }

Just a question...

I really like the look of the landscape based alertview you use in this. Is there a way to generalize it to use it as a replacement for UIAlertController? I need something with image and landscape capabilities. If you know of anything let me know. I'll take a look at this project later and see how it is made up. Thank you for the hard work.

whose view is not in the window hierarchy!

I get this error: "Sparrow.SPRequestPermissionDialogInteractiveViewController: ... whose view is not in the window hierarchy!".

I setup the RequestPermission like this:

var permissionAssistant = SPRequestPermissionAssistant.modules.dialog.interactive.create(with: [.Location, .PhotoLibrary, .Notification])

override func viewDidAppear(animated: Bool) {
        permissionAssistant.present(on: self)
}

Thanks.

VoiceRecognition permission ?

Hey !

Love your work, sincerely !
I need to ask the user for voice recognition (Speech Kit) API, could you add it ?

Thanks !

segmentation fault: 11 error

@BasThomas @ivanvorobei @mgt-la @RobertGolosynsky @telunc I love this project very much. But there is an issue. Every time I download the project and build it I get a command failed due to signal: segmentation fault: 11 error. I tried everything from cleaning the project, to transferring the files directing into my project to using cocoa pods and nothing worked. Can you please help me resolve this so I can use this project.

[REQ]is There a way to use RequestPermission with OneSignal ?

Hi, i'm currently using OneSignal for my push notifications in my iOS project.
To instantiate OneSignal, i have to do `OneSignal.initWithLaunchOptions(....)' in the Application.DidFinishingLaunchingWithOption func of the Application Delegate.
This automatically fires the standard request for Push Permissions.

I'd Like to use RequestPermission before all of this happens, but seems i can't because i've to instantiate RequestPermission in a Controller (and none is created at the Application Delegate flow of the app).

Is there a way/workaround ?

Thanks!

Victor

Dismiss on tap

It would be great to have the possibility to dismiss dialog view controller when user taps area outside it

CLLocationManager created in wrong thread

After user grants always on location usage I see the following warning in XCode console.
And looks like it's the cause of rare crashes in production.

2017-08-10 14:48:20.317102 MY_APP[902:377336] A location manager (0x15fec6c0) was created on a dispatch queue executing on a thread other than the main thread. It is the developer's responsibility to ensure that there is a run loop running on the thread on which the location manager object is allocated. In particular, creating location managers in arbitrary dispatch queues (not attached to the main queue) is not supported and will result in callbacks not being received

black color

@ivanvorobei How can I change the black background color of the rhombus pattern. Which file is it so I can change it. Ive tried every single file and couldn't find it myself. I would appreciate it if you could help me find the property. for it. Thanks.

Cant get dialog to segue after receiving permission

I am using the isAllowed as documented and when checking if all permissions are granted, it will not print it out let alone segue.. can I have a code sample of checking for a permission and segueing on didHide()

Hide header view

I don't want 'headerView' to appear in dialog. I don't really get its purpose.
request-permission_presenters

See highlighted part - that's the only thing I want to leave.
How can I achieve that?
Thank you for your work

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.