authorize callback was not called in SwiftUI app
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.
I have 2 questions (because I'm seeing the same thing)
- What version of iOS are you targeting
- Do you also have the Strava app installed when you're running your test?
@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.
hi, do you have a full example in SwiftUI?
Actually, I was able to get this working 😅 we can close it.
I had to instantiate my client using a regular AppDelegate