Login flow not calling completion in iOS 11

login
ios
bug

#1

I am trying to use Twitter Kit to authenticate with Twitter. However, the logIn method does not seem to call the completion block. Here is my code:

print("foo")
Twitter.sharedInstance().logIn(completion: { (session, error) in
  print("bar")
  if session != nil {
    print("signed in as \(session!.userName)")
    self.doStuff()
  } else {
    print("error: \(error.localizedDescription)")
  }
})

foo is printing, so I know the code reaches that point. The login flow appears, and I sign in. However, bar is never printed, and neither is signed in as or error.

I am testing on a Simulator iPhone 8 running iOS 11 and have TwitterKit 3.2.1 installed through CocoaPods.


#2

I am having the same issue with the newest TwitterKit 3.0, the completion block is never called in the code below.
Can you guys confirm it is a bug? In the meanwhile is there any work around so that we won’t get stocked on this and wait for the fix?

debugPrint("start")
TWTRTwitter.sharedInstance().logIn(completion: { (session, error) in
      debugPrint("end")
      guard error == nil else {
             debugPrint(error!.localizedDescription)
             return
      }
})

#3

Oops, my bad. Just found out I accidentally delete the url handler in the AppDelegate. After adding the url handler back to AppDelegate, it works properly again.