Failed to get images from camera DJI OSMO - ios

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.

Related

Why is admob consent form not loading on actual devices?

I am trying to implement Admob for my iOS app. The form loads on the Xcode simulator devices. I am located in the US, but I have used the following code to test that the Consent SDK is working for European users. When I use this with a simulator, the form and ads load.
PACConsentInformation.sharedInstance.debugIdentifiers = ["SPECIFIC_TO_MY_DEVICE"]
PACConsentInformation.sharedInstance.debugGeography = PACDebugGeography.EEA
The form does not load on my physical device with this configuration. The form also did not load when I used testflight to distribute a test version to a test user in the EU. Subsequently, the ads did not load on "European" devices.
When the form should load, I get an error from the below block of code. Also. I get the error WebKitDomain Error 101. My ATS settings are set up in the plist per the Admob documentation.
thisForm.load {(_ error: Error?) -> Void in
if let error = error {
print("Error loading form: \(error.localizedDescription)")
//I am getting the error here.
} else {
thisForm.present(from: self) { (error, userPrefersAdFree) in
print("in present handler")
if let error = error {
// Handle error.
print("error presenting: \(error.localizedDescription)")
} else if userPrefersAdFree {
//TODO: find a way to disable ads
} else {
// Check the user's consent choice.
//let status = PACConsentInformation.sharedInstance.consentStatus
}
}
}
Does anyone know what may be causing these errors with physical devices? I have tried with a real ad id and a test ad id.
Present consent form only if the following equals true
If requestLocationInEEAOrUnknown == true {
//present consent form
}
else {
//do whatever is needed
}

RPScreenRecorder stopRecording block not getting called

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.

Can use DJI SDK to replicate "Pitch Lock" feature of DJI Go app?

I'm trying to replicate the "Pitch Lock" on / off feature of the DJI Go app. How can I do this?
I'm using XCode 8.2.1, building for iOS 10.1, connecting to an Osmo Mobile with an iPhone 6s attached. The Osmo Mobile has the latest firmware (version 01.30.01.52).
Everything works so far (registerApp, connecting via bluetooth, getting handheld button presses, getting gimbal battery updates, getting gimbal updates).
Setting setGimbalWorkMode to either .freeMode or .yawFollowMode doesn't seem to have any effect. No error is returned in the completion block, but there's no effect on Gimbal operation.
The gimbal behaves as if it is in .freeMode (always moves to the exact direction handheld stick is pointing), but DJIGimbalDelegate only receives .yawFollowMode updates (which is what the pitchLock mode should do).
Setting setGimbalWorkMode to other modes results in an error (as expected with Osmo Mobile device).
Here's how I'm trying to toggle pitchLock on/off.
#IBAction func pitchLockPressed(_ sender: UIButton) {
pitchLock = !pitchLock
if let gimbal = fetchGimbal() {
var workMode : DJIGimbalWorkMode = .freeMode // .freeMode .fpvMode and .unknown return error using Osmo Mobile
if pitchLock {
workMode = .yawFollowMode
}
gimbal.setGimbalWorkMode(workMode, withCompletion: { (error) in
if (error != nil) {
print("error workMode: \(error?.localizedDescription)")
self.pitchLock = !(self.pitchLock) // back to previous
}
})
}
}
Here's the delegate, which only reports .yawFollowMode no matter what I do:
func gimbal(_ gimbal: DJIGimbal, didUpdate gimbalState: DJIGimbalState) {
// var needUpdate = false
if lastReportedWorkMode != gimbalState.workMode {
lastReportedWorkMode = gimbalState.workMode
switch lastReportedWorkMode {
case DJIGimbalWorkMode.fpvMode:
print("FPV\n")
case DJIGimbalWorkMode.freeMode:
print("Free\n")
case DJIGimbalWorkMode.yawFollowMode:
print("Yaw-follow\n")
case DJIGimbalWorkMode.unknown:
print("Unknown\n")
}
}
Anyone getting setGimbalWorkMode to actually change gimbal modes?

Updating to Xcode 7 Beta 5 & Swift 2 produced multiple errors

I updated Xcode to the new Xcode 7 beta 5. In doing so, it converted to Swift 2, but then created even more errors. Right now, I am completely stuck, and don't know what to do, because although all my errors are gone, my app will not work correctly.
My problem is this:
if(self.myOutput3 as? NSObject == true) {
print("IT IS TRUE")
PFUser.logInWithUsernameInBackground(self.myOutput1 as! String, password: "xxx") { (user: PFUser?, error: NSError?) -> Void in
if error == nil {
print("It Worked!")
// self.presentViewController(destViewController, animated: true, completion: nil)
let instillation = PFInstallation.currentInstallation()
instillation["user"] = PFUser.currentUser()
instillation.saveInBackgroundWithBlock(nil)
self.performSegueWithIdentifier("toTimeline", sender: self)
} else {
// self.enterButton.enabled = false
self.errorAlert()
print("Couldn't log in...")
}
}
} else {
print("IT IS FALSE")
self.performSegueWithIdentifier("continueTheSignIn", sender: self)
// self.move()
}
The program will perform the toTimeline segue, but not the continueTheSignIn . I don't see any logical reason that this is not working. Could anyone point me in the right direction?
Also, I am having an error in my messages feature.
cell.textView!.linkTextAttributes = [NSForegroundColorAttributeName:cell.textView!.textColor]
This is giving me the error "Cannot assign a value of type '[String : UIColor?]' to a value of type '[String: AnyObject]!'
I was not previously getting this error in Swift / Xcode 6.4, so I don't know how to fix it.
Additionally, once I bypass this to get into my app to see if my other features are working, most of my UITableViews are not displaying any information. One is, however the rest load the correct amount of rows, but display nothing. What could this be? Also, no Parse pictures are being displayed correctly either. These are even more concerning than the other problems...
Here is the picture after I deleted and re added the segue under a diff. name.
Parse wont support the beta version . it needs a full version . I have contacted them based on a similar issue . They said they will update the parse to work with xcode7 once the full version of xcode7 is released.

progressBlock in getDataInBackgroundWithBlock not called

My Swift app uses Parse.com as the backend. Among other things, I store images for user profiles. I store two versions of the same image: one thumbnail and one full sized image. When the user taps on the thumbnail, it is enlarged. The app then loads the full sized version and presents it on top of the enlarged thumbnail when loading is complete. Since the thumbnail image looks blurry while the full sized one is loading, I've implemented a circular progress bar that shows the loading progress, giving visual feedback of what's going on.
This is the method that handles this process (progressCircle is a CAShapeLayer):
func fetchFullImage() {
photoObject.fetchIfNeededInBackgroundWithBlock { (fetchedObject: PFObject!, error: NSError!) -> Void in
if error == nil {
// After fetching object, now we get the full sized image
let userFullImageFile = fetchedObject["fullImage"] as PFFile
userFullImageFile.getDataInBackgroundWithBlock( {
(imageData: NSData!, error: NSError!) -> Void in
if error == nil {
println(">> Success! Full image retrieved.")
self.fullImageView.image = UIImage(data: imageData)
// Hide the progress indicator
self.progressCircle.hidden = true
// Fade in and show the image
self.showFullImage()
}
},
progressBlock: {(percentDone: CInt) -> Void in
println("Loading... \(percentDone)")
// Prints out progress percentage under wifi, but not under 3G!
self.progressCircle.strokeEnd = CGFloat(percentDone) / 100.0
})
} else {
println(error)
}
}
}
Now this is the funny part. When I run the app on a real device connected via wifi, everything goes as expected: the progress circle grows as the image is loaded, etc. Now when I turn off wifi and the same device is connected via 3G, the progress circle does not grow. Essentially, what happens is that the progressBlock closure is not called (I can see this because the println statement produces no result). The image loads after a while (the completion closure is called), and is presented correctly, but there is no way for me to show the progress.
I am trying to find the logic behind this. I could almost understand it if it was the opposite (image loading so fast over wifi that the progress was not visible), but over 3G images take a few seconds to load, during which period nothing seems to happen.
Does anyone have an idea of what can keep progressBlock from being called here? I want to be able to provide the "loading in progress" visual feedback.
Thanks in advance!

Resources