I am trying to add Twitter login to my Xcode project. My main login is Facebook but my app uses Twitter info and since ACAccountStore().requestAccessToAccounts is deprecated for iOS 11, I have to use the Twitter API. I installed the TwitterKit pod. I added the following to my app delegate:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()
Database.database().isPersistenceEnabled = true
Twitter.sharedInstance().start(withConsumerKey: "the key from twitter", consumerSecret: "the secret from twitter")
return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
}
and my plist looks like:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>fbxxxxxx</string>
</array>
</dict>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>twitterkit-xxxxx</string>
</array>
</dict>
</array>
<key>CFBundleVersion</key>
<string>1</string>
<key>FacebookAppID</key>
<string>xxxxx</string>
<key>FacebookDisplayName</key>
<string>Smartter</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbapi</string>
<string>fb-messenger-share-api</string>
<string>fbauth2</string>
<string>fbshareextension</string>
<string>twitter</string>
<string>twitterauth</string>
</array>
now I have a view controller where I am adding the login button like so:
let logInButton = TWTRLogInButton(logInCompletion: { session, error in
if (session != nil) {
print("signed in as \(session?.userName)");
} else {
print("error: \(error?.localizedDescription)");
}
})
logInButton.center = self.view.center
self.view.addSubview(logInButton)
when I click the button, I am getting Request failed: unauthorized (401) in the console. If I build it on my iPod using 11.2.1 the login will open since I have the Twitter app installed on this device. I included SafariServices.framework and I followed all of the Twitter instructions. Any thoughts?