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

Present SFSafariViewController only for http and https schemes #655

Merged
merged 5 commits into from
Apr 8, 2019

Conversation

dusi
Copy link
Contributor

@dusi dusi commented Apr 2, 2019

📲 What

Fixes an issue that we've been seeing recently that caused SFSafariViewController to crash when passed a URL that doesn't have http or https scheme (i.e. FB live stream). The fallback solution should now be testing whether the url can be opened and opening it in that case.

🤔 Why

This crash has recently escalated quite a bit during an update of Throw Throw burrito.

🛠 How

As much as this is simple if/else condition...in order to test this we have to conform to a new protocol UIApplicationType and use a mock object.

✅ Acceptance criteria

  • Go to Update page and tap on any link
  • Go to Update page and tap on link to a live stream

@dusi dusi requested a review from ifbarrera April 2, 2019 23:34
@@ -132,12 +132,6 @@ internal final class CheckoutViewController: DeprecatedWebViewController {
self.present(vc, animated: true, completion: nil)
}

fileprivate func goToSafariBrowser(url: URL) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There were 6 duplicated functions thorough our codebase...it should now be much DRYer

public extension UIViewController {
static var supportedURLSchemes = ["http", "https"]

func goTo(url: URL, application: UIApplicationType = UIApplication.shared) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this dependency injection is totally fine - just wondering if we want to deviate from using Environment at this point in time?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you elaborate a bit? Not sure where you going with Environment? This injection is mostly for testing purposes

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, yes I mean we currently do all dependency injection through AppEnvironment/Environment, so this kind of injection (passing into a function) is fine, it's just that the rest of our injection hasn't been done that way. I'm more opening this up for discussion than anything else, I am not particularly opinionated about it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh right...I'll see what I can do and try to inject this through AppEnvironment instead

@dusi dusi added the blocked a PR that is blocked for external reasons label Apr 3, 2019
Copy link
Contributor

@justinswart justinswart left a comment

Choose a reason for hiding this comment

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

lgtm!

@dusi dusi removed the needs review label Apr 3, 2019
Copy link
Contributor

@ifbarrera ifbarrera left a comment

Choose a reason for hiding this comment

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

Nice! Thanks for fixing this 🙏

@dusi dusi removed the blocked a PR that is blocked for external reasons label Apr 5, 2019
@dusi dusi merged commit 7017918 into master Apr 8, 2019
@dusi dusi deleted the fallback-opening-urls branch April 8, 2019 17:54
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.

4 participants