Ошибка Twitterkit 3.0 «TWTRInvalidInitializationException» в ios

Я использовал ткань без проблем, но после нового обновления twitterkit 3.0 я следовал всему документу по установке, но когда я использую TWTRComposer, я получаю сбой приложения со следующим сообщением: «'TWTRInvalidInitializationException', причина: 'Попытка войти в систему или лайкнуть твит без действующая схема URL-адресов Twitter Kit, настроенная в настройках приложения». Не могу найти решение.

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

Нет проблем с запуском приложения, но когда я нажимаю кнопку, чтобы поделиться в твиттере, вызывается твиттер-композитор, а в строке «composer.show» приложение вылетает. Мне нужно было использовать twitter sdk из-за изменения функции удаления встроенной учетной записи ios11


person Samin    schedule 20.06.2017    source источник
comment
вы можете добавить twitterKit с помощью pod pod 'TwitterKit'   -  person Brijesh Shiroya    schedule 20.06.2017
comment
да, я установил модуль, и все коды работают хорошо... ошибка возникает в действии кнопки общего доступа к приложению.... строка composer.show   -  person Samin    schedule 20.06.2017
comment
вы реализуете ключ fb и ключ twitter в той же URLSchema   -  person Brijesh Shiroya    schedule 20.06.2017
comment
да, ключ fb и twitter совпадают, но даже удаление ключа fb не решило проблему   -  person Samin    schedule 20.06.2017


Ответы (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>
person Brijesh Shiroya    schedule 20.06.2017
comment
задача решена. Проблема была с инфоплистом. Я добавил ключи в свой основной список, но забыл о другой цели. Приведенный выше код также работал. Глупый... :( - person Samin; 21.06.2017
comment
У вас такая же проблема, не могли бы вы обновить свой исходный пост о том, что вы исправили или в чем была проблема? - person Bowenac; 19.02.2018