mattdonnelly / Swifter

[DEPRECATED] :bird: A Twitter framework for iOS & OS X written in Swift
MIT License
2.37k stars 388 forks source link

SwiftUI Support #293

Open NoahKamara opened 4 years ago

NoahKamara commented 4 years ago

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

meteochu commented 4 years ago

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.

steipete commented 4 years ago

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.

umair-shams commented 4 years ago

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

DennisMoschina commented 4 years ago

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

steipete commented 4 years ago

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

DennisMoschina commented 4 years ago

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?

meteochu commented 4 years ago

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

hossainehsani1982 commented 3 years ago

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?

AndreFormSpicyApps commented 2 years ago

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