Skip to content

Commit

Permalink
Update to 3.1.1
Browse files Browse the repository at this point in the history
Fix names of property and functions.
  • Loading branch information
ivanvorobei committed May 25, 2019
1 parent e0001e9 commit a7a338f
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 63 deletions.
62 changes: 31 additions & 31 deletions Example/SPPermission/Frameworks/SPPermission/SPPermission.swift
Expand Up @@ -43,16 +43,16 @@ public enum SPPermission {
return manager.isDenied
}

public static func request(_ permission: SPPermissionType, with complectionHandler: @escaping ()->()) {
public static func request(_ permission: SPPermissionType, with сompletionHandler: @escaping ()->()) {
let manager = self.getManagerForPermission(permission)
if let usageDescriptionKey = permission.usageDescriptionKey {
guard let _ = Bundle.main.object(forInfoDictionaryKey: usageDescriptionKey) else {
print("SPPermission Warning - \(usageDescriptionKey) for \(permission.name) not found in Info.plist")
return
}
}
manager.request(withComlectionHandler: {
complectionHandler()
manager.request(withCompletionHandler: {
сompletionHandler()
})
}
}
Expand All @@ -63,7 +63,7 @@ fileprivate protocol SPPermissionInterface {

var isDenied: Bool { get }

func request(withComlectionHandler complectionHandler: @escaping ()->()?)
func request(withCompletionHandler сompletionHandler: @escaping ()->()?)
}

extension SPPermission {
Expand Down Expand Up @@ -110,11 +110,11 @@ extension SPPermission {
return AVCaptureDevice.authorizationStatus(for: AVMediaType.video) == AVAuthorizationStatus.denied
}

func request(withComlectionHandler complectionHandler: @escaping ()->()?) {
func request(withCompletionHandler сompletionHandler: @escaping ()->()?) {
AVCaptureDevice.requestAccess(for: AVMediaType.video, completionHandler: {
finished in
DispatchQueue.main.async {
complectionHandler()
сompletionHandler()
}
})
}
Expand Down Expand Up @@ -147,18 +147,18 @@ extension SPPermission {
return notificationSettings?.authorizationStatus
}

func request(withComlectionHandler complectionHandler: @escaping ()->()?) {
func request(withCompletionHandler сompletionHandler: @escaping ()->()?) {
if #available(iOS 10.0, *) {
let center = UNUserNotificationCenter.current()
center.requestAuthorization(options:[.badge, .alert, .sound]) { (granted, error) in
DispatchQueue.main.async {
complectionHandler()
сompletionHandler()
}
}
} else {
UIApplication.shared.registerUserNotificationSettings(UIUserNotificationSettings(types: [.badge, .sound, .alert], categories: nil))
DispatchQueue.main.async {
complectionHandler()
сompletionHandler()
}
}

Expand All @@ -176,11 +176,11 @@ extension SPPermission {
return PHPhotoLibrary.authorizationStatus() == PHAuthorizationStatus.denied
}

func request(withComlectionHandler complectionHandler: @escaping ()->()?) {
func request(withCompletionHandler сompletionHandler: @escaping ()->()?) {
PHPhotoLibrary.requestAuthorization({
finished in
DispatchQueue.main.async {
complectionHandler()
сompletionHandler()
}
})
}
Expand All @@ -196,11 +196,11 @@ extension SPPermission {
return AVAudioSession.sharedInstance().recordPermission == .denied
}

func request(withComlectionHandler complectionHandler: @escaping ()->()?) {
func request(withCompletionHandler сompletionHandler: @escaping ()->()?) {
AVAudioSession.sharedInstance().requestRecordPermission {
granted in
DispatchQueue.main.async {
complectionHandler()
сompletionHandler()
}
}
}
Expand All @@ -217,12 +217,12 @@ extension SPPermission {
return EKEventStore.authorizationStatus(for: EKEntityType.event) == .denied
}

func request(withComlectionHandler complectionHandler: @escaping ()->()?) {
func request(withCompletionHandler сompletionHandler: @escaping ()->()?) {
let eventStore = EKEventStore()
eventStore.requestAccess(to: EKEntityType.event, completion: {
(accessGranted: Bool, error: Error?) in
DispatchQueue.main.async {
complectionHandler()
сompletionHandler()
}
})
}
Expand All @@ -246,20 +246,20 @@ extension SPPermission {
}
}

func request(withComlectionHandler complectionHandler: @escaping ()->()?) {
func request(withCompletionHandler сompletionHandler: @escaping ()->()?) {
if #available(iOS 9.0, *) {
let store = CNContactStore()
store.requestAccess(for: .contacts, completionHandler: { (granted, error) in
DispatchQueue.main.async {
complectionHandler()
сompletionHandler()
}
})
} else {
let addressBookRef: ABAddressBook = ABAddressBookCreateWithOptions(nil, nil).takeRetainedValue()
ABAddressBookRequestAccessWithCompletion(addressBookRef) {
(granted: Bool, error: CFError?) in
DispatchQueue.main.async() {
complectionHandler()
сompletionHandler()
}
}
}
Expand All @@ -276,12 +276,12 @@ extension SPPermission {
return EKEventStore.authorizationStatus(for: EKEntityType.reminder) == .denied
}

func request(withComlectionHandler complectionHandler: @escaping ()->()?) {
func request(withCompletionHandler сompletionHandler: @escaping ()->()?) {
let eventStore = EKEventStore()
eventStore.requestAccess(to: EKEntityType.reminder, completion: {
(accessGranted: Bool, error: Error?) in
DispatchQueue.main.async {
complectionHandler()
сompletionHandler()
}
})
}
Expand All @@ -297,12 +297,12 @@ extension SPPermission {
return EKEventStore.authorizationStatus(for: EKEntityType.reminder) == .denied
}

func request(withComlectionHandler complectionHandler: @escaping ()->()?) {
func request(withCompletionHandler сompletionHandler: @escaping ()->()?) {
let eventStore = EKEventStore()
eventStore.requestAccess(to: EKEntityType.reminder, completion: {
(accessGranted: Bool, error: Error?) in
DispatchQueue.main.async {
complectionHandler()
сompletionHandler()
}
})
}
Expand All @@ -318,10 +318,10 @@ extension SPPermission {
return SFSpeechRecognizer.authorizationStatus() == .denied
}

func request(withComlectionHandler complectionHandler: @escaping ()->()?) {
func request(withCompletionHandler сompletionHandler: @escaping ()->()?) {
SFSpeechRecognizer.requestAuthorization { status in
DispatchQueue.main.async {
complectionHandler()
сompletionHandler()
}
}
}
Expand All @@ -337,10 +337,10 @@ extension SPPermission {
return MPMediaLibrary.authorizationStatus() == .denied
}

func request(withComlectionHandler complectionHandler: @escaping ()->()?) {
func request(withCompletionHandler сompletionHandler: @escaping ()->()?) {
MPMediaLibrary.requestAuthorization() { status in
DispatchQueue.main.async {
complectionHandler()
сompletionHandler()
}
}
}
Expand Down Expand Up @@ -378,7 +378,7 @@ extension SPPermission {
return CLLocationManager.authorizationStatus() == .denied
}

func request(withComlectionHandler complectionHandler: @escaping ()->()?) {
func request(withCompletionHandler сompletionHandler: @escaping ()->()?) {

switch self.type {
case .AlwaysAndWhenInUse:
Expand All @@ -388,7 +388,7 @@ extension SPPermission {

SPPermissionAlwaysAuthorizationLocationHandler.shared!.requestPermission { (authorized) in
DispatchQueue.main.async {
complectionHandler()
сompletionHandler()
SPPermissionAlwaysAuthorizationLocationHandler.shared = nil
}
}
Expand All @@ -400,7 +400,7 @@ extension SPPermission {

SPPermissionWhenInUseAuthorizationLocationHandler.shared!.requestPermission { (authorized) in
DispatchQueue.main.async {
complectionHandler()
сompletionHandler()
SPPermissionWhenInUseAuthorizationLocationHandler.shared = nil
}
}
Expand All @@ -425,12 +425,12 @@ extension SPPermission {
return false
}

func request(withComlectionHandler complectionHandler: @escaping ()->()?) {
func request(withCompletionHandler сompletionHandler: @escaping ()->()?) {
let manager = CMMotionActivityManager()
let today = Date()

manager.queryActivityStarting(from: today, to: today, to: OperationQueue.main, withHandler: { (activities: [CMMotionActivity]?, error: Error?) -> () in
complectionHandler()
сompletionHandler()
manager.stopActivityUpdates()
})
}
Expand Down
2 changes: 1 addition & 1 deletion SPPermission.podspec
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "SPPermission"
s.version = "3.1.0"
s.version = "3.1.1"
s.summary = "Request permissions with dialog. For customise implement DataSource protocol. Check permissions."
s.homepage = "https://github.com/IvanVorobei/RequestPermission"
s.source = { :git => "https://github.com/IvanVorobei/RequestPermission.git", :tag => s.version }
Expand Down

0 comments on commit a7a338f

Please sign in to comment.