【问题标题】:Twitterkit 3.0 'TWTRInvalidInitializationException' error in iosiOS 中的 Twitterkit 3.0 'TWTRInvalidInitializationException' 错误
【发布时间】:2017-11-22 21:21:51
【问题描述】:

我使用的面料没有问题,但是自从新的 twitterkit 3.0 更新以来,我遵循了所有安装文档,但是当我使用 TWTRComposer 时,我得到了应用程序崩溃并显示以下消息:“'TWTRInvalidInitializationException',原因:'尝试登录或喜欢在应用设置中未设置有效 Twitter 工具包 URL 方案的推文。”似乎无法找出解决方案。

// Swift
    let composer = TWTRComposer()

    composer.setText("just setting up my Twitter Kit")
    composer.setImage(image.image)

    // Called from a UIViewController
    composer.show(from: self.navigationController!) { (result) in
        if (result == .done) {
        print("Successfully composed Tweet")
        } else {
        print("Cancelled composing")
        }
    }

以下是应用委托 didFinishLaunchingWithOptions 代码

Twitter.sharedInstance().start(withConsumerKey:"xxxxxxxxxxxx", consumerSecret:"xxxxxxxxxxxxxxxxxxxxxxxxxxxxx")

以下是我的 infoPlist 代码

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>twitterkit-consumentkeyxxxxxxx</string>
            <string>fbkeyxxxxxxxxxxxx</string>
            <string>xxxxxxxxx</string>
        </array>
    </dict>
</array>
<key>LSApplicationQueriesSchemes</key>
<array>
    <string>fbapi</string>
    <string>fb-messenger-api</string>
    <string>fbauth2</string>
    <string>fbshareextension</string>
    <string>twitter</string>
    <string>twitterauth</string>
</array>

在应用程序启动时不是没有问题,但是当我按下按钮在 twitter 上分享时,twitter 作曲家被调用并且在“composer.show”行应用程序崩溃。由于 ios11 内置帐户功能的更改,我需要使用 twitter sdk 删除

【问题讨论】:

  • 你可以通过 pod "pod 'TwitterKit'" 来添加 twitterKit
  • 是的,我确实安装了 pod,所有代码都运行良好...应用程序共享按钮操作中发生错误...composer.show 行
  • 你在同一个 URLSchema 中实现了 fb key 和 twitter key
  • 是的 fb 和 twitter 密钥是相同的,但即使删除 fbkey 也不能解决问题

标签: ios swift twitter twitterkit


【解决方案1】:

您需要像这样单独添加密钥:

<key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>fb-fbid-</string>
            </array>
        </dict>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>twitterkit-twitterKey</string>
            </array>
        </dict>
    </array>

【讨论】:

  • 问题已解决。问题出在 infoplist 上。我在主 plist 中添加了键,但忘记了我的另一个目标。上面的代码也有效。傻... :(
  • 遇到同样的问题,您能否更新您的原始帖子以说明您修复了什么或问题是什么?
猜你喜欢
  • 2017-11-01
  • 2018-02-09
  • 2017-11-02
  • 2014-05-14
  • 2011-12-26
  • 1970-01-01
  • 2018-06-03
  • 1970-01-01
  • 2012-07-20
相关资源
最近更新 更多