首页 > 解决方案 > 推特登录 swift 4

问题描述

我想在我的应用程序中实现 twitter 登录,但出现错误。

Class TWTRAppAuthProvider is implemented in both /Users/mohamedeldewaik/Library/Developer/CoreSimulator/Devices/1F7EFA9B-EB86-4E18-8386-284E21A73F92/data/Containers/Bundle/Application/37DD8EB8-2854-44CB-ABAD-3FDADA0FCD1E/alharamin pass.app/Frameworks/TwitterKit.framework/TwitterKit (0x105296548) and /Users/mohamedeldewaik/Library/Developer/CoreSimulator/Devices/1F7EFA9B-EB86-4E18-8386-284E21A73F92/data/Containers/Bundle/Application/37DD8EB8-2854-44CB-ABAD-3FDADA0FCD1E/alharamin pass.app/Frameworks/TwitterCore.framework/TwitterCore (0x10510e370). One of the two will be used. Which one is undefined.

我在下面的代码中尝试了这个,但它崩溃了

TWTRTwitter.sharedInstance().logIn(completion: { (session, error) in
            if (session != nil) {
                print("signed in as \(session?.userName)");
            } else {
                print("error: \(error?.localizedDescription)");
            }
        })

这是我的应用委托

import TwitterKit


@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {


var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

TWTRTwitter.sharedInstance().start(withConsumerKey:"XzbZgtanfchiPGRRpII1gu70Z",consumerSecret: "4cNlyYssitGQjoWob4eGnBYeCVP20yVNL9P7w9fI4TzhO4RGKg")

    return true
}

func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
    if TWTRTwitter.sharedInstance().application(app, open: url, options: options) {
        return true
    }

    return true
  }
}

那么如何在没有这个错误的情况下实现 twitter 我越来越多地搜索解决方案,但我没有得到正确的答案。

标签: iosswiftauthenticationtwitter

解决方案


您是否在仪表板中添加了回调 URL,如下所示

twitterkit-CONSUMERKEY://

推荐阅读