lundi 4 juillet 2016

Twitter Login View Didn't Pop Up using STTwitter

I am currently building a Twitter login in my Twitter client.

I installed STTwitter through CocoaPods in Xcode and follow the example - "loginOnTheWebAction" in STTwitterDemoIOS.

However, the Twitter web login didn't show up in my simulator once I pressed the "Login Button". The console prints:


login Pressed

1

4


Here's my code:

// MARK: Action
@IBAction func loginPressed(sender: AnyObject) {
    print("login Pressed")

    let twitter = STTwitterAPI(OAuthConsumerKey: TwitterClient.Constants.ConsumerKey, consumerSecret: TwitterClient.Constants.ConsumerSecret)

    print("1")

    twitter.postTokenRequest({ (url, oauthToken) in
        print("2")
        let controller = self.storyboard!.instantiateViewControllerWithIdentifier("TwitterAuthViewController") as! TwitterAuthViewController
        self.presentViewController(controller, animated: true, completion: {
            let request = NSURLRequest(URL: url)
            controller.webView.loadRequest(request)
        })
        }, authenticateInsteadOfAuthorize: false,
           forceLogin: true,
           screenName: nil,
           oauthCallback: "myapp://twitter_access_tokens/") { (error) in
            print(error)
            self.debugTextLabel.text = "Failed login"
    }

    print("4")
}

So, what is the problem that the program didn't do it? Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire