You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.

Forum Discussion

NeilHowarth's avatar
NeilHowarth
Helpful | Level 6
6 years ago

SwiftyDropBox SwiftyDropbox.MobileSafariViewController not in the window hierarchy

Hi, I have developed an application in Xcode (macOS) for iOS and I have integrated the SwiftyDropBox API. I have followed all the instructions in the README, but when I make a call to open a link to DropBox I get the following error.

Warning: Attempt to present <SwiftyDropbox.MobileSafariViewController: 0x7fb17981d800> on <Scipple_V2_0.ViewController: 0x7fb177c29d00> whose view is not in the window hierarchy!

I have Googled this to death but can't find an answer.

The initial DropboxClientsManager.setupWithAppKey seems to work (I am using the App Key I get from the App Console in DropBox.

Can anyone give me any suggestions how to fix this?

Thanks

Neil

 

 

 

 

  • Hi,

    I think you're right but not sure what I was doing wrong, the call is in my viewcontroller, however I tried

    DropboxClientsManager.authorizeFromController(UIApplication.shared, controller: UIApplication.shared.keyWindow!.rootViewController!, openURL: { (url: URL) -> Void in UIApplication.shared.open(url, options: [:], completionHandler: nil) })

    i.e. using rootViewController instead of self and it worked.

    Thanks for your response

    Neil


    Greg-DB wrote:

    When/where are you calling authorizeFromController?

    This error message generally indicates that the authorization window can't be displayed because it relies on yourViewController, but theViewController wasn't in the window hierarchy (yet?) at time of the call. Perhaps your ViewController wasn't presented (or was already dimissed) at the time? 


     

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Staff rankDropbox Staff

    When/where are you calling authorizeFromController?

    This error message generally indicates that the authorization window can't be displayed because it relies on yourViewController, but theViewController wasn't in the window hierarchy (yet?) at time of the call. Perhaps your ViewController wasn't presented (or was already dimissed) at the time? 

    • NeilHowarth's avatar
      NeilHowarth
      Helpful | Level 6

      Hi,

      I think you're right but not sure what I was doing wrong, the call is in my viewcontroller, however I tried

      DropboxClientsManager.authorizeFromController(UIApplication.shared, controller: UIApplication.shared.keyWindow!.rootViewController!, openURL: { (url: URL) -> Void in UIApplication.shared.open(url, options: [:], completionHandler: nil) })

      i.e. using rootViewController instead of self and it worked.

      Thanks for your response

      Neil


      Greg-DB wrote:

      When/where are you calling authorizeFromController?

      This error message generally indicates that the authorization window can't be displayed because it relies on yourViewController, but theViewController wasn't in the window hierarchy (yet?) at time of the call. Perhaps your ViewController wasn't presented (or was already dimissed) at the time? 


       

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,882 PostsLatest Activity: 32 minutes ago
325 Following

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!