Swiftpack.co -  cp3hnu/RxPrivacyManager as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
cp3hnu/RxPrivacyManager
Privacy manager in RxSwift
.package(url: "https://github.com/cp3hnu/RxPrivacyManager.git", from: "6.0.0")

RxPrivacyManager

Privacy manager for iOS based on RxSwift

Currently supported:

  • ☑ Camera
  • ☑ Photos
  • ☑ Location Services
  • ☑ Microphone
  • ☑ Contacts
  • ☑ Speech

Each has a framework that you can add separately to your project.

Usage

Before, to take photo like this.

func buttonTapped() {
  let status = AVCaptureDevice.authorizationStatus(for: .video)
  switch status {
  case .notDetermined:
   AVCaptureDevice.requestAccess(
     for: AVMediaType.video,
     completionHandler: { granted in
       if granted {
         onMainThread {
           takePhoto()
         }
       } else {
         presentAlertController()
       }
     })
  case .authorized:
    takePhoto()
  default:
    presentAlertController()
  }
}

/// To open camera permission
func presentAlertController() {
  let alert = UIAlertController(title: title, message: message, preferredStyle: .alert)
  let cancelAction = UIAlertAction(title: "Cancel", style: .cancel) { _ in
    // ...
  }
  let settingAction = UIAlertAction(title: "Setting", style: .default) { _ in
    if let settingsUrl = URL(string: UIApplication.openSettingsURLString) {
      UIApplication.shared.openURL(settingsUrl)
    }
  }
  alert.addAction(cancelAction)
  alert.addAction(settingAction)
  alert.preferredAction = settingAction
  present(alert, animated: true, completion: nil)
}

Now, just a function. It's so easy!!!

import PrivacyManager
import PrivacyPhoto

// In UIViewController and subclasses
PrivacyManager.shared.privacyCameraPermission(presenting: self, authorized: {
  takePhoto()
})

Screenshot

For the first time

Without authorization

Installation

Carthage

github "cp3hnu/PrivacyManager"
  • Drag and drop PrivacyManager.framework, PrivacyPhoto.framework or other related framework from /Carthage/Build/iOS/ to Linked Frameworks and Libraries in Xcode (Project>Target>General>Linked Frameworks and Libraries)
  • Add new run script
/usr/local/bin/carthage copy-frameworks
  • Add Input files
$(SRCROOT)/Carthage/Build/iOS/PrivacyManager.framework
$(SRCROOT)/Carthage/Build/iOS/PrivacyPhoto.framework
...
other related framework

Swift Package

File -> Swift Packages -> Add Package Dependency, then search rxprivacymanager.

Dependencies

Requirements

  • Swift 5.0
  • Xcode 10.0
  • iOS 9+ or iOS 10+(with Speech )

License

Released under the MIT license. See LICENSE for details.

GitHub

link
Stars: 3
Last commit: 4 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Dependencies

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API