推特登录出错后没有拿到错误返回

参考:http://blog.csdn.net/pz789as/article/details/53486568


前不久将推特的授权登录加入到自己的项目中来,今天测试时发现,在没有翻墙时,点击推特登录之后一直没有反应,然后看log发现,推特本身是给出了提示:

did encounter error with message "Error obtaining user auth token.": Error Domain=TWTRLogInErrorDomain Code=-1 "" UserInfo={NSLocalizedDescription=}

 

但是我这边也都对error做了处理和打印,却并没有接收到错误信息,导致应用一直停在waiting状态,无法操作!

调用推特登录代码如下:

[[Twitter sharedInstance] logInWithMethods:TWTRLoginMethodWebBased completion:^(TWTRSession* session, NSError* error) {
    if (session){
      NSLog(@"signed in as %@", [session userName]);
      [self twlCallback:CB_CODE_LOGIN result:
       [NSString stringWithFormat:@"{\"userName\": \"%@\",\"userID\": \"%@\",\"authToken\": \"%@\",\"authTokenSecret\": \"%@\"}",
        [session userName],
        [session userID],
        [session authToken],
        [session authTokenSecret]
        ]
       ];
    }else{
      NSLog(@"error: %@", [error localizedDescription]);
      [self twlCallback:CB_CODE_ERROR
                 result:[NSString stringWithFormat:@"{\"id\":\"%@\", \"dsc\":\"%@\"}",
                         ERROR_LOGIN,
                         [error localizedDescription]]];
    }
  }];

后面log在判断session外面发现,根本没有回调这个函数。

于是在网上找答案,然后在推特的论坛上找到这么一个答案:

https://twittercommunity.com/t/problem-using-twitterkit-to-login-via-oauth/73379

Thanks for reaching out on this. Have you made any customizations to the TWTRLoginMethod enum defined in Twitter.h along with the [Twitter logInWithMethods:completion:] method? By default, Twitter Kit will choose log in methods in the following order [System Account] -> [SFSafariViewController] -> [UIWebView]. With the TWTRLoginMethod enum, the developer can choose which methods to use when providing the user with the ability to log in using Twitter.


个人觉得应该是登录的方式不对,于是乎,将上面的代码中的

TWTRLoginMethodWebBased

改成

TWTRLoginMethodAll

就可以拿到结果啦,它会提示timeout,这样就可以做下一步操作了!心情瞬间舒畅了很多啊

改了之后的提示是这样的:

did encounter error with message "Unable to authenticate using the system account.": Error Domain=NSURLErrorDomain Code=-1001 "The request timed out."

然后就可以弹出提示框了:



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

苏小败在路上

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值