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

SwiftUI support? #639

Open
cacaosteve opened this issue Dec 16, 2020 · 5 comments
Open

SwiftUI support? #639

cacaosteve opened this issue Dec 16, 2020 · 5 comments
Labels

Comments

@cacaosteve
Copy link

I'm wondering about SwiftUI support?

@mesopelagique
Copy link
Contributor

#626 ?

@MoMitch
Copy link

MoMitch commented Feb 27, 2021

Issue is:
SwiftUI has a new method of catching callback urls.

Solution: We should have a way to pass in a url response ourselves to the auth object and let it handle it like a normal callback.

@MoMitch
Copy link

MoMitch commented Feb 27, 2021

For the meantime, you can do something like this:


                LoginView().onAppear(perform: {
                        // test init our API classes here
                        sharedTwitterClient.logDetails();
                })
                .onOpenURL { url in
                    // TODO: Ensure this is a valid auth login & details
                    
                    print("url",url);
                    isLoggedIn = true;
                    
                    
                    let notification = Notification(name: OAuthSwift.didHandleCallbackURL, object: nil,
                        userInfo: ["OAuthSwiftCallbackNotificationOptionsURLKey": url])
                    
                    
                    NotificationCenter.default.post(notification)
                }

This will re-route all URL's redirecting to the app to the callback function for OAuthSwift.

Note that you probably want to parse it and make sure it's an auth token, and not a deep link etc. first. This was just a quick test.

We call 'logDetails' on sharedTwitterClient which prints out some data, but more importantly instantiates a shared global var and initializes it by connecting to OAuthSwift2 and our twitter details.

@dadixon
Copy link

dadixon commented Apr 17, 2023

When I run this, I keep getting an error message The operation couldn’t be completed. (OAuthSwiftError error -3.).

@phimage
Copy link
Member

phimage commented Apr 17, 2023

When I run this, I keep getting an error message The operation couldn’t be completed. (OAuthSwiftError error -3.).

did you try to read the code?

  1. look for -3 -> missingState
  2. look for missingState -> only one instance with a boolean saying to check or not state
  3. set the boolean to true and test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants