PermissionsService 0.2.0

PermissionsService 0.2.0

TestsTested
LangLanguage SwiftSwift
License BSD
ReleasedLast Release Jun 2017
SwiftSwift Version 3.0
SPMSupports SPM

Maintained by Yuriy Trach, Max Vitruk, Sergiy Loza, OverSwift.


Downloads

Total152
Week53
Month125

Installs

Apps14
Apps WeekApps This Week 3
Pod Tries1
powered by Segment

GitHub

Stars10
Watchers14
Forks4
Issues0
Contributors5
Pull Requests0

Code

Files8
LOCLines of Code 236


  • By
  • Lemberg Inc

PermissionsService

An easy way to do permissions requests & handling automatically.

  1. Why do you need it?
  2. Features
  3. Supported Permission Types
  4. Installation with CocoaPods
  5. How To Use
  6. Customizing
  7. Requirements
  8. Author
  9. License

Why do you need it?

This library is an easy way to handle notDetermined, authorized, 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. Of cause, it is not a silver bullet, but a good tool for your project!

Features

  • [x] Customise or localise alerts messages via ServiceMessages protocol
  • [x] Automatic alert creating and presenting
  • [x] Opportunity for users to easy change permissions in Settings

Supported Permission Types

  • Calendar
  • Camera
  • Contacts
  • Gallery
  • Location
  • Microphone
  • Reminder

How To Use

  1. Configure your project in all ways needed for chosen permission type. For example, in a case of gallery, add specific key to your .plist file.

  2. Implement ServiceDisplay 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.

  3. Add Permission<T: PermissionService> object with a type you needed and use prepare(_:) method for request permission and presenting alert to the user.

  Permission<Gallery>.prepare(for: self, callback: { (granted) in
      if granted {
          //present library
      } else {
          //perform specific functions 
      }
    })
  1. Enjoy!

Customizing

You can add custom alerts messages for denied and restricted cases by creating new struct which conform to ServiceMessages protocol.

struct CameraMessages: ServiceMessages {
    
    let deniedTitle = "Access denied"
    let deniedMessage = "You can enable access to camera in Privacy Settings"
    let restrictedTitle = "Access restricted"
    let restrictedMessage = "Access to camera is restricted"
    
}

To use your custom messages put them in prepare(_:) method, like this:

  Permission<Camera>.prepare(for: self, with: CameraMessages()) { (granted) in
     if granted {
         print("Granted")
     } else {
         print("Error")
     }

 }

Requirements

Author

Lemberg Solutions

iOS Platform

License

ios-permissions-service is available under the BSD license. See the LICENSE file for more info.