delba / Permission

A unified API to ask for permissions on iOS
MIT License
2.9k stars 320 forks source link

Bluetooth permission on IOS<13 #151

Open aviya-smila opened 3 years ago

aviya-smila commented 3 years ago

I have an issue with IOS pre 13, the callback for permission.request isn't being called. is there a way to callback with authorized automatically?

kaiserabliz commented 3 years ago

I don't think callback works for Bluetooth permission authorization change. I suggest you check the authorization status in viewDidLoad for your action or use UIApplication.didBecomeActiveNotification key with NotificationCenter. Or this might answer your question: Replace code in Bluetooth.swift if #available(iOS 13.0, *) { switch CBCentralManager().authorization { case .restricted: return .disabled case .denied: return .denied case .notDetermined, .allowedAlways: break @unknown default: return .notDetermined } } else { switch CBPeripheralManager.authorizationStatus() { case .restricted: return .disabled case .denied: return .denied case .notDetermined, .authorized: break @unknown default: return .notDetermined } }