I have an iphone 11pro ios 15.0 device. The video is playable but When I call 'deleteAssets' the 'completionHandler' never runs.
PHPhotoLibrary.shared().performChanges {
PHAssetChangeRequest.deleteAssets(deleteAccess as NSFastEnumeration)
} completionHandler: { [weak self] success, error in
//Never run
}
Does anyone know why this happens? Does anyone have a solution for this?
I do not know. But after I reset my iPhone, everything is back to normal. Maybe it's a system error.
Related
I am using ReplayKit to record the screen. However, I have a very strange issue with having video buffers. When user taps record button, the following method is called;
rpScreenRecorder.startCapture { (sampleBuffer, bufferType, error) in
if let error = error {
print(error.localizedDescription)
}
switch bufferType {
case .video:
print("video")
case .audioApp:
print("audioApp")
case .audioMic:
print("audioMic")
#unknown default:
print("default")
}
} completionHandler: { (error) in
if let error = error {
print(error.localizedDescription)
}
}
The problem is, bufferType does not have video. When I print all cases, audioMic and audioApp is returned forever but video is never returned.
I can easily repeat this problem only on the first launch when I remove the app and install it again. It works as expected in other cases.
p.s: I had a look at other issues before asking this question. None of them solved the problem.
After spending days and nights to solve this issue, I finally came up with a solution.
Simply, the reason was about the main window
Main window is important for replay kit because it is recording the main window.
I was using different windows to hide some views from the recorded video. I also changed windowLevel of the main window. Today, I noticed that removing every adjustment related to main window solved the problem. (other windows have no effect.)
I have searched enough but failed to get a solution.
I am using ReplayKit to record the screen of my app. I have started recording the screen by calling
let sharedRecorder = RPScreenRecorder.shared()
sharedRecorder.startRecording() { error in
if let error = error {
self.showScreenRecordingAlert(message: error.localizedDescription)
}
}
When I am pressing the stopRecord button I am calling
let sharedRecorder = RPScreenRecorder.shared()
sharedRecorder.stopRecording { previewViewController, error in
if let error = error {
self.showScreenRecordingAlert(message : error.localizedDescription)
return
}
}
But the issue that I am facing is, the program control does not enter inside the stopRecording block.
When I am doing po sharedRecorder.isRecording, it always returns false.
I have done everything I know but failed to get a solution.
If you having this above issue with your code i have found the solution for this.
let sharedRecorder = RPScreenRecorder.shared()
sharedRecorder.stopRecording { previewViewController, error in
if let error = error {
self.showScreenRecordingAlert(message : error.localizedDescription)
return
}}
Above Block will not call if you running your app on simulator so please use real device to test then above method will call definitely.
Thank you.
Just had this issue running XCode 9.4.1 and building onto iOS 11.4.0. Upgrading the phone to iOS 11.4.1 fixed the bug. I'm not sure if the difference in XCode versions is the root cause or if 11.4.0 was just broken.
I am using replay kit to save a video of my screen during gameplay but randomly on occasion startRecordingWithMicrophoneEnabled and recorder.stopRecordingWithHandler never enters the completion handler
it doesn't throw an error, it just runs and hangs indefinitely.
if recorder.available && recorder.microphoneEnabled {
recorder.startRecordingWithMicrophoneEnabled(true) { [unowned self] (error) in
if let unwrappedError = error {
print(unwrappedError.localizedDescription)
} else {
print("called")
self.manager.instructions.text = "Click to Start Game"
}
}
}
if recorder.available && recorder.microphoneEnabled {
print("initiating stop recording")
recorder.stopRecordingWithHandler { [unowned self] (RPPreviewViewController, error) in
print("in completion handler")
if let previewView = RPPreviewViewController {
print("will transition to gameplay video")
previewView.previewControllerDelegate = self
self.presentViewController(previewView, animated: true, completion: nil)
self.sessionHandler.session.stopRunning()
}
}
}
I was getting this same thing. Was working on one device, and not on another. Only difference was the working device was on iOS version 10.1.0 and the other was iOS version 10.0.2 - upgraded to 10.2.0 and it started working immediately.
I had the same problem and just found its cause (or maybe just a cause). If your device is connected to a WiFi that has no internet access this problem occurs. If you connect it to a WiFi that has internet access or disable WiFi it works just fine. I guess when starting a recording, ReplayKit tries to connect to some Apple servers but never reaches them and also never times out. You can observe the same behavior with the App Store. When you are connected to a WiFi without internet it tries to load the store forever and never times out.
I'm working with DJI sdk to get the photographs taken with the camera osmo. The problem I have is that when I show a picture on the screen gives me the following error:
"ERROR: fetchThumbnailWithCompletion: ErrorDomain DJISDKErrorDomainCode = -1004 =" System is busy, Please retry later (Code: -1004). ""
So it is written in the sdk:
#IBAction func onShowThumbnailButtonClicked(sender: AnyObject) {
self.showThumbnailButton.enabled = false
if self.imageMedia?.thumbnail == nil {
// fetch thumbnail is not invoked yet
self.imageMedia?.fetchThumbnailWithCompletion({[weak self](error: NSError?) -> Void in
if error != nil {
self?.showAlertResult("ERROR: fetchThumbnailWithCompletion:\(error!.description)")
}
else {
self?.showPhotoWithImage(self!.imageMedia!.thumbnail!)
}
self?.showThumbnailButton.enabled = true
})
}
}
But I need to show 6 images, therefore I make 6 times (6 times using a do) what is inside the IBAction. Then at that time the error occurs, because if I do it only once that error does not happen.
In addition, selecting ok error that appears like still works for other images but the idea is that no such error appears.
Any idea how to fix it?
Please ensure you have switched the camera to download mode (https://developer.dji.com/iframe/mobile-sdk-doc/ios/Classes/DJICamera.html). If you have already done that, then add delay between photo shooting and download.
In my iOS 7 iPad app LAContext:evaluatePolicy sometimes returns SUCCESS without prompting the user to touch the ID button. And the Apple docs say “Evaluating a policy MAY involve prompting the user…”.
My authentication policy is set to LAPolicyDeviceOwnerAuthenticationWithBiometrics, the only choice I see. Why wouldn’t this prompt the user to touch the ID button every time I call evaluatePolicy? Is there a way I can require this behavior?
I have experienced a similar problem.
It is possible that you are declaring a global variable something like
let authenticationContext = LAContext()
and then use authenticationContext within your class methods and functions.
I have started declaring the constant in each function I use it like
func someAuthFunc() {
let authenticationContext = LAContext()
...
and my problem was solved.
I was asked each time I requested evaluateForContext ...
I hope this helps.
Cheers
For who have the same issue
It just happens from iOS 13 and above. The solution is trying to call evaluate function twice like this:
let systemVersion = UIDevice.current.systemVersion
// Trick here: Try to do a pre-evaluate
if systemVersion.compare("13.0", options: .numeric) != .orderedAscending {
context.evaluatePolicy(.deviceOwnerAuthentication, localizedReason: "Authenticate to open the app", reply: { (_, _) in
//Ignore callback here
})
}
context.evaluatePolicy(.deviceOwnerAuthentication, localizedReason: "Authenticate to open the app", reply: { (success, error) in
// Handle callback here
})
Tested and work well for all iOS 13.x.x versions so far.
I experience the same problem after iOS13 update. Not a good workaround but calling evaluatePolicy twice solved the problem for me
context.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: reason) { _, _ in
context.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: reason) { isSuccess, _ in
DispatchQueue.main.async {
if isSuccess {
success()
} else {
fail(authError?.localizedDescription ?? "User did not authenticate successfully")
}
}
}
}
This seems to be a bug on iOS 13, 13.1 and is planned to be fixed in 13.2. I'd suggest trying your code on the iOS 13.2 beta to see if it's any better.
source: iOS 13 Touch ID Delay/Bug