Unable to upload image using photo library - ios

I am getting this error after choosig image from gallery in ios app
errors encountered while discovering extensions: Error Domain=PlugInKit Code=13 "query cancelled" UserInfo={NSLocalizedDescription=query cancelled}
I have also added- Privacy- Photo Library photo description, camera description.
Also tried- OS_ACTIVITY_MODE disable
but still unable to fix

I am not sure what code you are using but one of the problems might be that you are not properly handling all the authorisation cases.
func performPermissionCheck() {
let authorisationStatus = PHPhotoLibrary.authorizationStatus()
switch authorisationStatus {
case .authorized:
print("Access granted")
case .notDetermined:
PHPhotoLibrary.requestAuthorization({ newStatus in
if newStatus == PHAuthorizationStatus.authorized {
print("success")}
})
case .restricted:
print("No access to album")
case .denied:
print("Permission Denied")
}
}

Related

AudioKit microphone does not init on first run

Good afternoon,
I am using the latest version of AudioKit (4.9 Master Branch) with Xcode 11.3 and am running into a strange permission problem. When a user launches an app for the first time, the OS asks for permission to use the microphone. After the user selects "Allow", the microphone does not work, but if you force quit the app and relaunch it the microphone works fine.
I created a function to test the state of the permission and placed it in viewDidLoad() :
func checkMic() {
switch AVAudioSession.sharedInstance().recordPermission {
case AVAudioSessionRecordPermission.granted:
print("Permission granted")
case AVAudioSessionRecordPermission.denied:
print("Pemission denied")
case AVAudioSessionRecordPermission.undetermined:
print("Request permission here")
AVAudioSession.sharedInstance().requestRecordPermission({ (granted) in
print("Mic Enabled")
})
#unknown default:
print("Not Working")
}
}
The function is only triggered during the first run but I have already initialized my AudioKit singleton class by this point. I have tried to reinitialize with no success. I have not encountered this before and am wondering if anyone else is experiencing this change or had a suggestion for it.
It seems that both the AKAnalizer and AKMicrophone are disabled when when iOS asks for permission to use the microphone. I needed to start both again. Hope this helps anyone in the same situation.
var audioCore = AudioCore.sharedInstance()
func checkMic() {
switch AVAudioSession.sharedInstance().recordPermission {
case AVAudioSessionRecordPermission.granted:
print("Permission granted")
case AVAudioSessionRecordPermission.denied:
print("Pemission denied")
case AVAudioSessionRecordPermission.undetermined:
print("Request permission here")
AVAudioSession.sharedInstance().requestRecordPermission({ (granted) in
print("Mic Enabled")
self.audioCore.microphone.start()
self.audioCore.analyzer.start()
print(self.audioCore.microphone.isStarted)
print(self.audioCore.analyzer.isStarted)
})
#unknown default:
print("Not Working")
}

Reactive Location - Handle success and failure block

It might be simple question.
I'm using Reactive Location, to get user's current location, please find my below code,
ReactiveLocation.authorizeAction.apply(.whenInUse).startWithResult {
switch $0 {
case let .success(status):
print("Current user permission status on WhenInUse is \(status)")
case let .failure(error):
print(error.localizedDescription)
}
}
Here error is .restricted and .denied, I want user to be presented with the error message according to error. How to identify it.
In above code, completion block looks like this,
Please help me to solve the issue.
I suggest learning more about Swift enum.
You can check for .restricted and .denied the same way you checked for .success and .failure.
The only difference is LocationAuthorizationError doesn't have associated values.
ReactiveLocation.authorizeAction.apply(.whenInUse).startWithResult {
switch $0 {
case let .success(status):
print("Current user permission status on WhenInUse is \(status)")
case let .failure(actionError):
switch actionError {
case .producerFailed(.restricted):
print("Authorization Restricted")
case .producerFailed(.denied):
print("Authorization Denied")
default:
break
}
}
}

How to go to settings directly if the permission to access photo library is denied in swift

class func checkPhotoLibraryPermission() {
// TODO: #Umer Complete this process as discussed
let photoAuthorizationStatus = PHPhotoLibrary.authorizationStatus()
switch photoAuthorizationStatus {
case .authorized:
print("Access is granted by user")
case .notDetermined:
PHPhotoLibrary.requestAuthorization({
(newStatus) in
print("status is \(newStatus)")
if newStatus == PHAuthorizationStatus.authorized {
/* do stuff here */
print("success")
}
else {
}
})
print("It is not determined until now")
case .restricted:
print("User do not have access to photo album.")
case .denied:
print("User has denied the permission.")
}
}
in case .denied
If we come first time to access photo library access permission is asked to user and if user do not allow permission, next time when user tries to access photo library it directly goes to settings where user can manually set permissions.

EKEventStore requestAccessToEntityType crashing app in iOS 10 and above

I have app in which I have to add events in default calendar which worked fine until iOS 10. Now in iOS 10 it is not granting access. I have set use legacy swift language version to yes. My code is
let eventStore = EKEventStore()
switch EKEventStore.authorizationStatusForEntityType(EKEntityType.Event) {
case .Authorized:
//access
case .Denied:
print("Access denied")
case .NotDetermined:
eventStore.requestAccessToEntityType(EKEntityType.Event, completion:
{[weak self] (granted: Bool, error: NSError?) -> Void in
if granted {
//access
} else {
print("Access denied")
}
})
default:
print("Case Default")
}
While debug my app is crashing at eventStore.requestAccessToEntityType in Xcode 8.
My app is live and I need to solve it. Any help is appropriated. Thanks in advance.
On iOS 10 builds, you need to set a description message for the permission alert on Info.plist
Important: An iOS app linked on or after iOS 10.0 must include in its
Info.plist file the usage description keys for the types of data it
needs to access or it will crash. To access Reminders and Calendar
data specifically, it must include NSRemindersUsageDescription and
NSCalendarsUsageDescription, respectively.
from Apple Docs
let eventStore = EKEventStore()
switch EKEventStore.authorizationStatus(for: .event) {
case .authorized: break
//access
case .denied:
print("Access denied")
case .notDetermined:
eventStore.requestAccess(to: .event, completion:
{[weak self] (granted: Bool, error: Error?) -> Void in
if granted {
//access
} else {
print("Access denied")
}
})
default:
print("Case Default")
}
With XCode 8 and swift 3, this is the new format. Did you test your app on iOS 10.

Microphone Access Prompt Not Being Presented

In my audio recording application I'm trying to ask the user for access to the microphone. However, I keep getting the .NotDetermined case and no prompt. The documentation states that the Not Determined case will prompt the user but that doesn't seem to be the case.
#IBAction func recordTapped(recordButton: UIButton!){
let microPhoneStatus = AVCaptureDevice.authorizationStatusForMediaType(AVMediaTypeAudio)
switch microPhoneStatus {
case .Authorized:
// Has access
println("access")
vibrate()
recordNow()
case .Denied:
// No access granted
println("denied")
case .Restricted:
// Microphone disabled in settings
println("mic disabled in settings")
case .NotDetermined:
// Didn't request access yet
AVCaptureDevice.requestAccessForMediaType(AVMediaTypeAudio, completionHandler: nil)
println("Not determined")
}
}

Resources