Twitter 登录因 TWTRInvalidInitializationException 而崩溃 [英] Twitter sign in crashes with TWTRInvalidInitializationException

查看:71
本文介绍了Twitter 登录因 TWTRInvalidInitializationException 而崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试使用 Twitter 登录时,我的应用程序崩溃,并显示错误消息

My app crashes when i try to login with twitter, with an error message

在应用设置中未设置有效 Twitter Kit URL Scheme 的情况下尝试登录或点赞推文.请参阅 https://dev.twitter.com/twitterkit/ios/installation更多信息.

Attempt made to Log in or Like a Tweet without a valid Twitter Kit URL Scheme set up in the app settings. Please see https://dev.twitter.com/twitterkit/ios/installation for more info.

我已经使用fabric 应用了 twitter 登录.但是在将我的代码从 swift 2.3 转换为 swift 3 之后,它开始崩溃.我也更新了我的 pod 并重新应用了在没有织物的情况下再次登录的步骤,因为fabric 没有显示现在推特选项.但崩溃仍然存在.

I have applied twitter login using fabric.But after converting my code from swift 2.3 to swift 3, it started crashing.I have updated my pods too and reapplied the steps for sign in again without fabric, as fabric is not showing the twitter option now. But still the crash remains.

推荐答案

如果我理解正确的话,您已经将 Twitter 与 Fabric 一起使用,所以我假设您的 AppDelegate 中有这样的内容:

If i understand correctly you have used Twitter with Fabric, so i assume you had something like this in your AppDelegate:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    Fabric.with([Twitter.self])    
    return true
}

请注意,由于 Google 收购了 Fabric,您应该使用:

Note that since Google acquired Fabric you should use:

Twitter.sharedInstance().start(withConsumerKey:"yourAppKey", consumerSecret:"yourAppSecret")

您还应该配置您的 Info.plist 以包含 TwitterKit 的 URL Scheme,如下所示:

You should also configure your Info.plist to include TwitterKit's URL Scheme like this:

  1. 在 CFBundleURLSchemes 中,你应该有这个值的字符串键twitterkit-yourAppKey"
  2. 在 LSApplicationQueriesSchemes 中,您应该添加那些twitter"和twitterauth"

供参考:https://dev.twitter.com/twitterkit/ios/installation

PS:确保您的 CFBundleURLSchemes 中的twitterkit-yourAppKey"是第 0 项,当前版本 (3.0.3) 中存在一些奇怪的错误,如果它不是第一个崩溃的项目.

PS: Make sure that "twitterkit-yourAppKey" in your CFBundleURLSchemes is Item 0, there is some weird bug in the current version (3.0.3) and if its not the first item it crashes.

这篇关于Twitter 登录因 TWTRInvalidInitializationException 而崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆