2

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

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.

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.

7

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
}

Note that since Google acquired Fabric you should use:

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

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

  1. In CFBundleURLSchemes you should have string key with this value "twitterkit-yourAppKey"
  2. In LSApplicationQueriesSchemes you should add those "twitter" and "twitterauth"

For reference: https://dev.twitter.com/twitterkit/ios/installation

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.

  • The last part (make sure twitterkit-{yourAppKey} is item 0) did the trick for me, thanks! – mclaughlinj Jul 31 '17 at 16:14
  • The code they give you for Twitter.sharedInstance().start(... can't be copy pasted. You have to put your keys in manually. I had just copy pasted it without looking, and they had a fake key and secret set in the code examples. – brycejl Aug 10 '17 at 1:31
0

Like the answer above wrote, I was doing this and it crashed:

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>fbmykey</string>
            <string>twitterkit-mykey</string>
        </array>
    </dict>
</array>

Then changed to this and it worked:

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>twitterkit-mykey</string>
            <string>fbmykey</string>
        </array>
    </dict>
</array>

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.