 import UIKit
 import SafariServices
 
-@available(iOS 11.0, *)
 class MainViewController: UIViewController, FoursquareAuthClientDelegate {
 
     @IBOutlet weak var tokenTextView: UITextView!
     @IBOutlet weak var searchButton: UIButton!
 
-    private var session: SFAuthenticationSession? = nil
+    private var session: NSObject?
 
     private let foursquareAuthUrlFormat = "https://foursquare.com/oauth2/authenticate?client_id=%@&response_type=token&redirect_uri=%@"
     private let clientId = "(YOUR_CLIENT_ID)"

            return
        }

        self.session = SFAuthenticationSession(url: authURL, callbackURLScheme: callbackURLScheme.scheme) { url, error in
            print(url, error)
            // fsoauthexample://authorized#access_token=XXXXXXXXXXXXXX
            if let urlString = navigationAction.request.url?.absoluteString,
                urlString.range(of: "access_token=") != nil {

                // Auth Success
                if let accessToken = urlString.components(separatedBy: "=").last {
                    delegate?.foursquareAuthViewControllerDidSucceed(accessToken: accessToken)
                    dismiss(animated: true, completion: nil)
                    decisionHandler(WKNavigationActionPolicy.cancel)
                    return
                }
            }

        }
        session?.start()
return

        let client = FoursquareAuthClient(clientId: clientId, callback: callback, delegate: self)
        client.authorizeWithRootViewController(self)
    }




    @IBAction func didTapLoginButton(_ sender: AnyObject) {
        // Open auth view
        if #available(iOS 11.0, *) {
            self.authorizeWithSFAuthenticationSession()
        } else {
            let client = FoursquareAuthClient(clientId: clientId, callback: callback, delegate: self)
            client.authorizeWithRootViewController(self)
        }
    }

    @available(iOS 11.0, *)
    func authorizeWithSFAuthenticationSession() {
        // Encode URL
        let authURLString = String(format: foursquareAuthUrlFormat, self.clientId, self.callback)
        guard let encodedURLString = authURLString.addingPercentEncoding(withAllowedCharacters: CharacterSet.urlQueryAllowed) else {
