ios 中的 Twitterkit 3.0 'TWTRInvalidInitializationException' 错误

Twitterkit 3.0 'TWTRInvalidInitializationException' error in ios

我使用 fabric 没有问题,但自从新的 twitterkit 3.0 更新以来,我遵循了所有安装文档,但是当我使用 TWTRComposer 时,我遇到应用程序崩溃并显示以下消息:“'TWTRInvalidInitializationException',原因:'Attempt made to在应用程序设置中未设置有效的 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")
        }
    }

以下是app delegate 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 正在调用并且 "composer.show" 行应用程序崩溃。由于 ios11 内置帐户功能删除

发生变化,我需要使用 Twitter SDK

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

<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>