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

authorize callback was not called in SwiftUI app #28

Open
antoniokly opened this issue May 20, 2020 · 5 comments · May be fixed by #31
Open

authorize callback was not called in SwiftUI app #28

antoniokly opened this issue May 20, 2020 · 5 comments · May be fixed by #31

Comments

@antoniokly
Copy link

antoniokly commented May 20, 2020

Hi there,
I have followed all the steps, added URI types, so I am able to open the Strava app, authorise and then redirect back to my app when calling StravaClient.sharedInstance.authorize { (result) in print(result) }
however the callback { (result) in print(result) } was not called.

It tried your example app, it worked! What am I still missing? I am writing my app using SwiftUI, that is the only difference I can spot.

@joeblau
Copy link

joeblau commented Aug 25, 2020

I have 2 questions (because I'm seeing the same thing)

  1. What version of iOS are you targeting
  2. Do you also have the Strava app installed when you're running your test?

@joeblau
Copy link

joeblau commented Aug 25, 2020

@antoniokly I figured it out!

If you're running a pure SwiftUI app this is what you need to do.

@main
struct MyApplication: App {
  var body: some Scene {
    WindowGroup {
      ContentView()
        .onOpenURL { url in
          // This is where you handle the scene opening a URL
          strava.handleAuthorizationRedirect(url)
        }
    }
  }
}

Once you set this up, you'll see the callback in authorized get called and you'll get your access token.

@joeblau joeblau linked a pull request Aug 25, 2020 that will close this issue
2 tasks
@MacChico1970
Copy link

hi, do you have a full example in SwiftUI?

@joeblau
Copy link

joeblau commented Feb 8, 2021

Actually, I was able to get this working 😅 we can close it.

@joeblau
Copy link

joeblau commented Feb 8, 2021

I had to instantiate my client using a regular AppDelegate

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

Successfully merging a pull request may close this issue.

3 participants