Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS, 13.1, url-handler not called #259

Closed
Appelg opened this issue Dec 11, 2019 · 6 comments
Closed

iOS, 13.1, url-handler not called #259

Appelg opened this issue Dec 11, 2019 · 6 comments

Comments

@Appelg
Copy link

Appelg commented Dec 11, 2019

I'm using xcode with iOS 13.1 as target.

I just copied the instructions for auth into my application.
I get redirected to the dropbox app and click "allow", but the following in app delegate is never hit:

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {

I think this may be because of something new and fancy called "Scene Delegate", but I have not had time to read up on that.

I guess we need to handle the url-redirect in the SceneDelegate.swift file instead?

Update:
Adding the following func to SceneDelegate.swift seems to work:

func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
        if let url = URLContexts.first?.url {
            print(url)
            
            if let authResult = DropboxClientsManager.handleRedirectURL(url) {
                switch authResult {
                case .success:
                    print("Success! User is logged into Dropbox.")
                case .cancel:
                    print("Authorization flow was manually canceled by user!")
                case .error(_, let description):
                    print("Error: \(description)")
                }
            }
        }
    }
@greg-db
Copy link
Contributor

greg-db commented Dec 11, 2019

Thanks for the report! I'm glad to hear you already got this working.

It looks like the relevant iOS documentation is here, under "Specifying the Scenes Your App Supports" > "Adopt Scene-Based Life-Cycle Semantics":

Adding support for scenes changes how your app responds to life-cycle events. In an app without scenes, the app delegate object handles transitions to the foreground or background. When you add scene support to your app, UIKit shifts that responsibility to your scene delegate objects. Scene life cycles are independent of one another, and independent of the app itself, so your scene delegate objects must handle the transitions.

If your app also supports iOS 12, you can handle life-cycle transitions in both your app delegate and scene delegate objects. UIKit notifies only one delegate object. In iOS 13 and later, UIKit notifies your scene delegate objects. In iOS 12 and earlier, UIKit notifies your app delegate.

I'll ask the team to update the SwiftyDropbox documentation with information on how to set up the authorization flow in an app that supports scenes like this.

@inPhilly
Copy link

inPhilly commented May 7, 2020

Doesn't look like the documentation has been updated yet. Am I wrong? This is pretty important.

@greg-db
Copy link
Contributor

greg-db commented May 7, 2020

@inPhilly That's correct, this issue is still open with the team; the documentation hasn't been updated yet.

@jem5519
Copy link

jem5519 commented Mar 4, 2021

Ran into the this same issue building a test app to work with SwiftyDropbox. It would be worth updating the docs for iOS.

@greg-db
Copy link
Contributor

greg-db commented Mar 4, 2021

@jem5519 Thanks for the note. I'll remind the team this still needs to be updated.

@greg-db
Copy link
Contributor

greg-db commented Apr 16, 2021

The documentation has been updated for this. Thanks all!

@greg-db greg-db closed this as completed Apr 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants