{"id":18643574,"url":"https://github.com/lemberg/ios-permissions-service","last_synced_at":"2025-09-03T03:36:09.777Z","repository":{"id":62450615,"uuid":"58943335","full_name":"lemberg/ios-permissions-service","owner":"lemberg","description":"An easy way to do permissions requests \u0026 handling automatically.","archived":false,"fork":false,"pushed_at":"2019-04-10T13:17:54.000Z","size":3658,"stargazers_count":24,"open_issues_count":1,"forks_count":11,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-08-16T02:31:45.101Z","etag":null,"topics":["calendar","camera","contacts","gallery","ios","microphone","permissions","privacy","swift"],"latest_commit_sha":null,"homepage":"http://blog.lemberg.co.uk/permissions-service-easy-way-handle-permissions-ios","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-4-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lemberg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-16T15:24:01.000Z","updated_at":"2023-04-08T18:58:43.000Z","dependencies_parsed_at":"2022-11-01T23:33:05.663Z","dependency_job_id":null,"html_url":"https://github.com/lemberg/ios-permissions-service","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/lemberg/ios-permissions-service","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemberg%2Fios-permissions-service","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemberg%2Fios-permissions-service/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemberg%2Fios-permissions-service/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemberg%2Fios-permissions-service/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lemberg","download_url":"https://codeload.github.com/lemberg/ios-permissions-service/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemberg%2Fios-permissions-service/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273386096,"owners_count":25096242,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-03T02:00:09.631Z","response_time":76,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["calendar","camera","contacts","gallery","ios","microphone","permissions","privacy","swift"],"created_at":"2024-11-07T06:07:24.707Z","updated_at":"2025-09-03T03:36:09.753Z","avatar_url":"https://github.com/lemberg.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\u003cp align=\"center\"\u003e \n\u003cimg src=\"http://i.piccy.info/i9/a78079fbf443139391c8bab158b8b6ed/1500892891/100777/1164536/800.png\"\u003e\n\u003c/p\u003e\n\n[![License](https://img.shields.io/cocoapods/l/PermissionsService.svg?style=flat)](http://cocoapods.org/pods/PermissionsService)\n[![Version](https://img.shields.io/badge/pod-v0.3.0-blue.svg?style=flat)](http://cocoapods.org/pods/PermissionsService) \n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![Swift Version](https://img.shields.io/badge/Swift-3.1%2B-orange.svg?style=flat)](http://cocoapods.org/pods/PermissionsService) \n[![iOS Platform](https://img.shields.io/badge/iOS-8.0%2B-blue.svg?style=flat)](http://cocoapods.org/pods/PermissionsService) \n[![By](https://img.shields.io/badge/By-Lemberg%20Solutions%20Limited-blue.svg?style=flat)](http://cocoapods.org/pods/PermissionsService)\n\nAn easy way to do permissions requests \u0026 handling automatically.\n\n1. [Why do you need it?](https://github.com/lemberg/ios-permissions-service#why-you-need-it)\n1. [Features](https://github.com/lemberg/ios-permissions-service#features)\n1. [Supported Permission Types](https://github.com/lemberg/ios-permissions-service#supported-permission-types)\n1. [Installation](https://github.com/lemberg/ios-permissions-service#installation)\n    1. [CocoaPods](https://github.com/lemberg/ios-permissions-service#cocoapods)\n    1. [Carthage](https://github.com/lemberg/ios-permissions-service#carthage)\n1. [How To Use](https://github.com/lemberg/ios-permissions-service#how-to-use)\n1. [Configurations](https://github.com/lemberg/ios-permissions-service#configurations) \n    1. [Custom alert messages](https://github.com/lemberg/ios-permissions-service#configurate-messages)\n    1. [Location permission](https://github.com/lemberg/ios-permissions-service#location-permission-types)\n1. [Requirements](https://github.com/lemberg/ios-permissions-service#requirements)\n1. [Author](https://github.com/lemberg/ios-permissions-service#author)\n1. [License](https://github.com/lemberg/ios-permissions-service#license)\n\n## Why do you need it?\n\nThis library is an easy way to handle `notDetermined`, `authorised`, `restricted` and `denied` cases without doing it by yourself. No more need to do error handling for `restricted` and `denied` cases, create and present to user specific alerts. \nOf cause, it is not a silver bullet, but a good tool for your project!\n\n## Features\n\n- [x] Customise or localise alerts messages via `Configuration`\n- [x] Automatic alert creating and presenting \n- [x] Opportunity for users to easily change permissions in Settings \n- [x] CoreLocation permission returns you completion block with user's decision \n- [x] Example project for easy understanding of framework \n\n## Supported Permission Types\n  \n* `Camera`  \n* `Contacts` \n* `Events`\n* `Gallery`  \n* `Location`\n* `MediaLibrary` \n* `Microphone` \n* `Reminder`\n* `Siri`\n* `SpeechRecognition` \n\n## Installation with CocoaPods\n\nios-permissions-service is available through [CocoaPods](http://cocoapods.org) and [Carthage](https://github.com/Carthage/Carthage)\n\n### CocoaPods\n\nTo install it, simply add one or several lines to your Podfile like this:\n\n```swift\n  pod \"PermissionsService/Location\"\n  pod \"PermissionsService/Camera\"\n```\n\nFull list of available permissions you can found [here](https://github.com/lemberg/ios-permissions-service#supported-permission-types). \n\n\u003e If you'll need, there is still a versions written on **Swift 3/4** which you can find in separate branches\n\nNow you need to run `pod update` command from you project folder and that's it!\n\n### Carthage\n\n1. Add the following line to your Cartfile:\n\n```swift\n  github \"lemberg/ios-permissions-service\"\n```\n\nIf you want to use a specific branch with another Swift version you can add branch name:\n\n```swift\ngithub \"lemberg/ios-permissions-service\" \"swift4\"\n```\n\n2. Run `carthage update --platform iOS` command from you project folder.\n\n3. Find the *Carthage/Build* folder, which is in your project folder. Drag and drop `PermissionsService.framework` file, to the *Linked Frameworks and Libraries* section in *General* settings tab of your project. \n\n4. Do to *Build Phases* settings tab. Click the “+” icon and choose *New Run Script Phase* if not exist. Add the following line to your script \n\n```swift\n  /usr/local/bin/carthage copy-frameworks\n```\n\n5. Add the framework's paths under *Input Files*:\n\n```swift\n  $(SRCROOT)/Carthage/Build/iOS/PermissionsService.framework\n```\n\n6. Add the framework's paths to the *Output Files*:\n\n```swift\n  $(BUILT_PRODUCTS_DIR)/$(FRAMEWORKS_FOLDER_PATH)/PermissionsService.framework\n```\n\n\u003e More info about using and configuring Carthage you can find [here](https://github.com/Carthage/Carthage#getting-started).\n\n#### Note!\n\nThere is an important note about installing, because of Apple's policy. Due to this policy regarding permission access, binaries may be rejected due to a perceived attempt to access privacy-sensitive data without a usage key, and then further rejected for not actually requesting permissions. This error will be when you'll try uploading to itunesconnect. \n\nBut there is a **solutuion**. You need to provide custom build flags *before building the dynamic framework* to only compile with permissions you request. \n\n1. Go to your project root directory and add `xcconfig` file named `PermissionConfiguration.xcconfig`. \n[Example of such file you can find here.](https://github.com/lemberg/ios-permissions-service/blob/master/Example/Pods/PermissionConfiguration.xcconfig)\n\n2. Comment lines which you don't want to use like this:\n\n```swift\n    \n    PERMISSION_CAMERA            = PERMISSION_CAMERA\n    PERMISSION_CONTACTS          = // PERMISSION_CONTACTS\n    \n```\n\nHere you can see an example of using only `Camera` permission. `Contacts` permission will be unavailable. \n\n3. Now you can run `carthage update --platform iOS` to compile framework. \n\n\u003e If you'll need to change available permissions, go to `PermissionConfiguration.xcconfig` file and modify it. Then update the framework again. \n\n\n## How To Use\n\n1. Configure your project in all ways needed for chosen permission type. For example, in a case of a gallery, add a specific key to your .plist file. \n\n2. Implement  `Permissible` protocol in your class. If it's not a `UIVIewController` class you should implement `showAlert(_:)` method, but if it is - there is a default implementation and you can leave it empty. \n\n3. Add `Permission\u003cT: PermissionService\u003e` object with a type you needed and use  `prepare(_:) ` method for request permission and presenting alert to the user. \n\n```swift\n\n  Permission\u003cGallery\u003e.prepare(for: self, callback: { (granted) in\n      if granted {\n          //present library\n      } else {\n          //perform specific functions \n      }\n    })\n\n```\n\nThis case if show a simple variant of use with default permission settings. \n\n\u003e Be aware that **Calendar** permission service named **Events**. \n\n4. Enjoy!\n\n## Configurations\n\nThis library gives you an opportunity to do some customising or configurations if you need it. \n\n### Configurate messages\n\nYou can add custom alerts messages for `denied` and `restricted` cases by creating new `struct` which conform to `ServiceMessages` protocol.\n\n```swift\n\nstruct CameraMessages: ServiceMessages {\n    \n    let deniedTitle = \"Access denied\"\n    let deniedMessage = \"You can enable access to camera in Privacy Settings\"\n    let restrictedTitle = \"Access restricted\"\n    let restrictedMessage = \"Access to camera is restricted\"\n    \n}\n```\n\nTo use your custom messages you need to use  `DefaultConfiguration` class. Let's init it!\n\n ```swift\n    let config = DefaultConfiguration(with: CameraMessages())\n ```\n\nAnd now put it in  `prepare(_:) ` method, like this:\n \n ```swift\n   Permission\u003cCamera\u003e.prepare(for: self, with: config) { (granted) in\n      if granted {\n          print(\"Granted\")\n      } else {\n          print(\"Error\")\n      }\n\n  }\n\n ```\n\n### Location permission types \n\nAs you can know, you can request two types of user location permission: `WhenInUse` and `Always`. \nFor choosing it you need to use configurations too.  Class `LocationConfiguration` is a subclass of `DefaultConfiguration` and have the same way to use. \n\nYou can init it only with type\n\n ```swift\n       let config = LocationConfiguration(.always)\n ```\n\nOr you can use it with your messages\n\n ```swift\n      let config = LocationConfiguration(.always, with: CustomLocationMessages())\n ```\n\nAnd then simply put it in your  `prepare(_:) ` method as you already did with `DefaultConfiguration`. \n\n ```swift\n   Permission\u003cLocation\u003e.prepare(for: self, with: config) { (granted) in\n      if granted {\n          print(\"Granted\")\n      } else {\n          print(\"Error\")\n      }\n\n  }\n\n ```\n \n \u003e If you still have some questions or issues (maybe even improvements!) feel free to open new issue or PR. \n\n\n## Requirements\n\n- [![Swift Version](https://img.shields.io/badge/Swift-3.1%2B-orange.svg?style=flat)](http://cocoapods.org/pods/PermissionsService) \n- [![iOS Platform](https://img.shields.io/badge/iOS-8.0%2B-blue.svg?style=flat)](http://cocoapods.org/pods/PermissionsService) \n- [![Xcode Version](https://img.shields.io/badge/Xcode-8.1%2B-blue.svg?style=flat)](http://cocoapods.org/pods/PermissionsService) \n\n## Author\n\n### [Lemberg Solutions](http://lemberg.co.uk) \n\n[![iOS Platform](http://lemberg.co.uk/sites/all/themes/lemberg/images/logo.png)](https://github.com/lemberg) \n\n## License\n\nios-permissions-service is available under the [BSD license](https://directory.fsf.org/wiki/License:BSD_4Clause). See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flemberg%2Fios-permissions-service","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flemberg%2Fios-permissions-service","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flemberg%2Fios-permissions-service/lists"}