1

I had used fabric with no issue but since new twitterkit 3.0 update I followed all the installation document but when I use TWTRComposer I get app crash with folowing message: "'TWTRInvalidInitializationException', reason: 'Attempt made to Log in or Like a Tweet without a valid Twitter Kit URL Scheme set up in the app settings." Can't seem to figure out solution.

// 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")
        }
    }

The folowing is app delegate didFinishLaunchingWithOptions code

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

The following is my infoPlist code

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

Not there are no issues on app start but when I press button to share on twitter, twitter composer is call and on "composer.show" line app crashes. I needed to use twitter sdk due to change in ios11 inbuilt account feature remove

Samin
  • 275
  • 5
  • 13

1 Answers1

10

You need to add key separately like this:

<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>
Brijesh Shiroya
  • 3,323
  • 1
  • 13
  • 20
  • 1
    problem solved. Issue was with infoplist. I added keys in my main plist but forgot for my another target. The above code worked as well. Silly... :( – Samin Jun 21 '17 at 05:29
  • 1
    Having the same issue, could you update your original post on what you fixed or what the problem was? – Bowenac Feb 19 '18 at 17:22