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

WIP: Make iOS twitter login default using SFSafariViewController #289

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

huiping192
Copy link
Contributor

@huiping192 huiping192 commented Jan 14, 2020

why

iOS authorize method need SFSafariViewControllerDelegate but if developer used TwitterKit before
sometime get confused.

TwitterKit implementation: https://github.com/twitter-archive/twitter-kit-ios/blob/4a69c9df030e979ecc60a320bda75c3797c5b079/TwitterKit/TwitterKit/Social/Syndication/API/TWTRWebAuthenticationFlow.m#L91

how

I create a internal view controller to implement SFSafariViewControllerDelegate inside the authorize method. And handle the SafariViewController event.

@huiping192 huiping192 force-pushed the feature/twitter-cancel branch 4 times, most recently from 077a170 to 10998d4 Compare January 15, 2020 02:57
@huiping192 huiping192 changed the title [WIP] make iOS twitter login default using SFSafariViewController make iOS twitter login default using SFSafariViewController Jan 15, 2020
@huiping192 huiping192 marked this pull request as ready for review January 15, 2020 02:58
@huiping192 huiping192 changed the title make iOS twitter login default using SFSafariViewController Make iOS twitter login default using SFSafariViewController Jan 15, 2020
Copy link
Contributor

@meteochu meteochu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this change is trying to make it closer to TwitterKit, it introduces some problems:

  1. Previous clients with custom SFSafariViewControllerDelegate implementations would lose their ability to specify behaviour when the SafariViewController is done. This was previous behaviour and we shouldn't remove that.
  2. Embedding a SFSafariViewController in another view controller just so that the parent view controller can be the concrete type that conforms to the delegate isn't an elegant solution. There's a more detailed comment on this inline.

*/

#if os(iOS)
func authorize(withCallback callbackURL: URL,
presentingFrom presenting: UIViewController?,
forceLogin: Bool = false,
safariDelegate: SFSafariViewControllerDelegate? = nil,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking change. We can't just rip this out since there are clients using this, unless we move this change to be a major update change. I suggest keeping the original code, but fallback to a default delegate when the user doesn't provide any safari delegate.

embedViewController(viewController: createWebViewController())
}

func embedViewController(viewController: UIViewController) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a fan of this at all. We shouldn't embed the view controller just to conform to SFSafariViewControllerDelegate. I propose having a default concrete object that conforms to the delegate that is owned by the Swifter object (that gets nil'd out when it's done) in the event the client provides a nil delegate. Either that, or the Swifter class itself can just conform to the SFSafariViewControllerDelegate that has a default behaviour of dismissing it on completion.

@huiping192
Copy link
Contributor Author

huiping192 commented Aug 19, 2020

@meteochu Thank you for your review. Sorry I don't notice the comment earlier.
I will try to fix this.

I`m making this pr status to wip

@huiping192 huiping192 changed the title Make iOS twitter login default using SFSafariViewController WIP: Make iOS twitter login default using SFSafariViewController Aug 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants