Swifter
Swifter copied to clipboard
SwiftUI Support
Hey, it would be nice if you could add support for SwiftUI or design the authentification process so that you don't have to use an UIViewController
To present a SFSafariViewController to get in-app login, we require a UIViewController to present from since it's based in UIKit. If you don't provide a presentingFrom
value for the authorize method, then the app will just open Safari to perform the login, which should still work.
You can embed a view controller in SwiftUI and push the presentation from that. That's what I currently use. Could be done a bit simpler, but overall it's fine and not a blocker to adopt SwiftUI.
@steipete Hi I am also using swifter in my swiftui project but I am new to swiftui, can you show me how to present the login process fo twitter using swiftui.
I would love that too. I am currently stuck, so if anyone has a working solution I would appreciate if they shared it.
I'm just using an embedded view controller to connect it - this is easy with SwiftUI.
I am able to get the website, but after I return to the app I am still not authorized. Would you mind posting a working code example?
@DennisMoschina Do you have the code in your AppDelegate (or SceneDelegate) to receive the authentication callback? You can refer to the sample project as a reference by looking at the non-SSO option. Here's a link to the sample. This callback is important as it allows Swifter to receive the token from Twitter and process the authentication request.
I am able to get the website, but after I return to the app I am still not authorized. Would you mind posting a working code example?
could you pleae post a copy of your code
I am able to get the website, but after I return to the app I am still not authorized. Would you mind posting a working code example?
could you please post the code for UIViewControllerRepresentable?
Got it working after reading this: https://www.andyibanez.com/posts/using-aswebauthenticationaession-swiftui/