Swifter icon indicating copy to clipboard operation
Swifter copied to clipboard

SwiftUI Support

Open NoahKamara opened this issue 4 years ago • 9 comments

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

NoahKamara avatar Feb 03 '20 17:02 NoahKamara

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.

meteochu avatar May 10 '20 05:05 meteochu

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 avatar Jun 21 '20 14:06 steipete

@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.

umair-shams avatar Oct 26 '20 13:10 umair-shams

I would love that too. I am currently stuck, so if anyone has a working solution I would appreciate if they shared it.

DennisMoschina avatar Dec 02 '20 19:12 DennisMoschina

I'm just using an embedded view controller to connect it - this is easy with SwiftUI.

steipete avatar Dec 02 '20 20:12 steipete

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 avatar Dec 03 '20 07:12 DennisMoschina

@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.

meteochu avatar Dec 03 '20 07:12 meteochu

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?

hossainehsani1982 avatar Aug 09 '21 19:08 hossainehsani1982

Got it working after reading this: https://www.andyibanez.com/posts/using-aswebauthenticationaession-swiftui/

AndreFormSpicyApps avatar Feb 03 '22 07:02 AndreFormSpicyApps