cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iOS - Problems connecting from own app to Dropbox when Dropbox App is installed

iOS - Problems connecting from own app to Dropbox when Dropbox App is installed

gcarl
Explorer | Level 4

Dear community,

 

since a few days I have the following strange situation.

 

I have developed an app for iOS which can store data on the Dropbox. The connection is set up as described in the manuals with the right settings in info.plist and the SceneDelegate (see below).

 

Everything works fine as long as the Dropbox app is not installed on the device. As soon as the Dropbox app is on the device my app doesn't get a  connection to the dropbox to exchange data. When launching my app it calls Dropbox to ask if I allow the access of my app. As soon as I confirm this, the return to my app doesn't work properly and the connection breaks. It seems that the  DropboxClientsManager.authorizedClient is not properly set.

The error is reproducible - removing Dropbox app: all works, installing Dropbox app: problem is there.

 

Does anyone have an idea, what I can do to fix it? I would assume that I have to change some settings?

My current settings are:

info.plist:

<key>LSApplicationQueriesSchemes</key>

<array>

<string>dbapi-8-emm</string>

<string>dbapi-2</string>

</array>

<key>CFBundleURLTypes</key>

<array>

<dict>

<key>CFBundleURLName</key>

<string></string>

<key>CFBundleURLSchemes</key>

<array>

<string>db-**************</string>

</array>

</dict>

</array>

 

and in the sceneDelegate:

// MARK: - Dropbox

    func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {

        if let url = URLContexts.first?.url {

            let oauthCompletion: DropboxOAuthCompletion = {

              if let authResult = $0 {

                  switch authResult {

                  case .success:

                      print("Success! User is logged into DropboxClientsManager.")

                  case .cancel:

                      print("Authorization flow was manually canceled by user!")

                  case .error(_, let description):

                      print("Error: \(String(describing: description))")

                  }

              }

            }

            DropboxClientsManager.handleRedirectURL(url, completion: oauthCompletion)

        }

    }

 

 

Thanks for your support

Regards gcarl

10 Replies 10

gcarl
Explorer | Level 4

Dear GrebDB,

 

I did various tests on several devices with the same effect.

But finality I think, I found a solution.

Although specified in the app declaration on Dropbox, that the app needs scopes "files.content.write" and "files.content.read" too, it didn't work

 

Hence I changed the scope request when initially calling the Dropbox to get access and included all scopes:

"

let scopeRequest = ScopeRequest(scopeType: .user, scopes: ["files.content.write", "files.content.read", "account_info.read"], includeGrantedScopes: false)

            DropboxClientsManager.authorizeFromControllerV2(

                UIApplication.shared,

                controller: self,

                loadingStatusDelegate: nil,

                openURL: { (url: URL) -> Void in UIApplication.shared.open(url, options: [:], completionHandler: nil) },

                scopeRequest: scopeRequest

            )

"

By doing so, it seems that the problem is fixed.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    gcarl Explorer | Level 4
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?