twitter登录swift 4

问题描述 投票:1回答:3

我想在我的应用程序中实现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我越来越多地搜索解决方案,但我得不到正确的答案。

ios swift twitter login
3个回答
2
投票

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

twitterkit-CONSUMERKEY://

1
投票

请在您的Twitter仪表板中添加一个回拨网址,如下所示(twitterkit-CONSUMERKEY://

enter image description here


0
投票

Twitter登录

buttonLogin = TWTRLogInButton(logInCompletion: { session, error in
            if (session != nil) {
                print("signed in as \(session!.userName)");
            } else {
                print("error: \(error!.localizedDescription)");
            }
        })
© www.soinside.com 2019 - 2024. All rights reserved.