Dear community,
I developed a cookbook-app for iOS to manage recipes. The app saves the recipe data in a json-file on a Dropbox folder, which can be defined by the user. If photos are linked to a recipe, these are saved separately in jpg-files on the Dropbox too. The recipe data are loaded when the app is started or when recipes are edited. The photos are loaded when the recipe, to which the photos are linked, is selected to be displayed.
As described in SwiftyDropbox manual, I do the authorization with the following workflow
func connectDropbox(withRequest request: Dropboxrequest) {
dropboxrequest = request
let scopeRequest = ScopeRequest(scopeType: .user, scopes: ["files.content.write", "files.content.read", "account_info.read"], includeGrantedScopes: true)
DropboxClientsManager.authorizeFromControllerV2(
UIApplication.shared,
controller: self,
loadingStatusDelegate: nil,
openURL: { (url: URL) -> Void in UIApplication.shared.open(url, options: [:], completionHandler: nil) },
scopeRequest: scopeRequest
)
}
and handle the redirect as described. All works fine so far. Unfortunately, the connection to the dropbox seems to be not stable.
Before reading or writing data, I check, if an authorized client exists as follows:
if let client = DropboxClientsManager.authorizedClient /*getClient()*/ {
dropboxrequest = .checkFile
client.files.download(path: aktuellesKochbuch.credentials.urlFile)
.response { response, error in
if let response = response {
let _ = response.0
let fileContents = response.1
self.finishInit(withData: fileContents, withError: false)
} else if let error = error {
switch error as CallError {
case .routeError:
self.finishInit(withData: Data(), withError: true)
default:
showAlert(withTitle: String(format: NSLocalString("E036 Dropbox access error: \n%@", comment: "E036 Fehler Dropboxzugriff"),error.description), withMessage: "Please check Dropbox status")
return
}
}
}
}
especially, if the app is in use for a longer time, it leads to the following Callerror:
E036 Fehler Dropboxzugriff: sessionTaskFailed (error: Error
Domain=NSURLErrorDomain
Code=-1005 "Die
Netzwerkverbindung wurde
unterbrochen."
Userinfo=<_kCFStreamErrorCodeKey=-4,
NSUnderlyingError=0x282391cb0 {Error
Domain=kCFErrorDomainCFNetwork Code=-1005 " (null)" UserInfo=<NSErrorPeerAddressKev=<CFData0x280ed5040[Ox212cdc580]>{length = 16,capacity = 16, bytes =
0x100201bba27d420e0000000000000000},
_kCFStreamErrorCodeKey=-4
_kCFStreamErrorDomainKey=4}},
NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask
...
One user, who is reporting many of these errors, has stored the data on a shared folder with another user in Dropbox.
Does anyone have an idea, what the reason for this instability could be?
Thanks for your support.
gcarl