TwitterKit is dismissing callee controller in airplane mode



Consider this example

  let controller = /** Some modal controller */

 Twitter.sharedInstance().logIn(with: controller, completion: { (session, error) -> Void in

If there’s no/bad internet connection /airplane mode, TwitterSDK will dismiss the controller immediately

Here are some call stacks which are showing that this call is made by the TwitterSDK itself

Potentially related issues:


I’m having similar trouble- TwitterKit is dismissing my (modally presented) view controller which is invoking -[Twitter loginWithCompletion:] when the user cancels authentication in the SFSafariViewController via the ‘Done’ button.

iOS 11 & 10, Xcode 9b6 & 8.3.3
TwitterKit 3.1.1


  1. My (modally presented) View Controller calls [[Twitter sharedInstance] loginWithCompletion:...]
  2. SFSafariViewController is presented to handle auth (simulator / no Twitter app)
  3. User taps Done in nav bar (cancels auth)
  4. My view controller is sent -dismissViewControllerAnimated:completion: from TwitterKit!

See backtrace:

* thread #1, queue = '', stop reason = breakpoint 22.1
  * frame #0: 0x000000010fc4bfd2 Redacted`-[LoginViewController dismissViewControllerAnimated:completion:](self=0x00007fb64c9990b0, _cmd="dismissViewControllerAnimated:completion:", flag=YES, completion=(null)) at LoginViewController.m:78
    frame #1: 0x0000000110204036 Redacted`__43-[Twitter performWebBasedLogin:completion:]_block_invoke.275 + 70
    frame #2: 0x00000001101d0235 Redacted`-[TWTRWebAuthenticationFlow failWithError:] + 104
    frame #3: 0x00000001101d0031 Redacted`__68-[TWTRWebAuthenticationFlow presentWebAuthenticationViewController:]_block_invoke + 65
    frame #4: 0x00000001101eb74d Redacted`-[TWTRWebAuthenticationViewController failWithError:] + 282
    frame #5: 0x00000001101eb519 Redacted`-[TWTRWebAuthenticationViewController safariViewControllerDidFinish:] + 64
    frame #6: 0x0000000113b49b95 SafariServices`-[SFSafariViewController remoteViewControllerWillDismiss:] + 128
    frame #7: 0x0000000113b3bb1d SafariServices`-[SFBrowserRemoteViewController willDismissServiceViewController] + 47

From searching the forums it looks like similar problems have occurred in previous releases of TwitterKit.

Edit: It appears performWebBasedLogin:completion: is attempting to dismiss the SFSafariViewController on Done, but I suspect this is already handled by the SafariServices framework.

Please help!

iOS 11 - TwitterKit 3 - The presenting view controller dismisses on clicking Done button in the web top left
Double navigation bars

Seeing the same thing. I tried passing nil as the viewController, or use the logIn method without a viewController parameter and had the same result.


I’m having the same issue, please help !




This is happening to me, the callee viewController is being dismissed if the app is not installed. Steps to reproduce:

  1. Make sure Twitter is no installed
  2. Call Twitter.sharedInstance().logIn(with: viewController)

TwitterKit logs the message and closes the callee vie controller:

  <error>Desktop applications only support the oauth_callback value 'oob'</error>
" UserInfo={NSLocalizedDescription=<?xml version="1.0" encoding="UTF-8"?>
  <error>Desktop applications only support the oauth_callback value 'oob'</error>


having the same issue …anyone got around it?
Im using TwitterKit 3


Having the same issue and it’s driving me crazy.


Seeing the same/similar thing right now. I am using TWTRComposerViewController, and on user tapping cancel in the UI, the calling vc is dismissed. It doesn’t happen if the calling vc is not presented modally.


This issue doesn’t seem to be fixed yet, is there a workaround?


Using latest twiiterkit, but still facing the same issue.
Twitter team, please solve this as soon as possible.


I’m having the same issue too.
Since TwitterKit is being discontinuated I think the best solution is to migrate to using the Twitter’s standard API itself or as a quick workaround try to check if Twitter app is installed on the device before calling the login.


I would certainly support the suggestion to migrate to an alternative solution.