Twitter登录-已完成登录,但未重定向到我的应用程序

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

正如标题所述,它停留在该状态。我没有找到搜索网络的解决方案。没有错误...使用ios swift

附上图片(希伯来语):它基本上说:“将您重定向回应用程序,可能需要一些时间。”

<< img src =“ https://image.soinside.com/eyJ1cmwiOiAiaHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS9wUTI0Ny5wbmcifQ==” alt =“正在被重定向”页面“>

代码: AppDelegate-

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

    FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)

    var configureError: NSError?
    GGLContext.sharedInstance().configureWithError(&configureError)
    assert(configureError == nil, "Error configuring Google services: \(configureError)")

    Fabric.with([Twitter.self])

    return true
}


//deprecaed - for support
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
    let directedByFB = FBSDKApplicationDelegate.sharedInstance().application(application, open: url, sourceApplication: sourceApplication, annotation: annotation)
    let directedByGoogle = GIDSignIn.sharedInstance().handle(url as URL!, sourceApplication: sourceApplication,annotation: annotation)
    return directedByFB || directedByGoogle
}


func application(application:UIApplication, openURL url: URL, options: [String: AnyObject]) -> Bool {
    if Twitter.sharedInstance().application(application, open: url, options: options) {
        return true
    }
    return GIDSignIn.sharedInstance().handle(url as URL!, sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication.rawValue] as? String, annotation: options[UIApplicationOpenURLOptionsKey.annotation.rawValue])
}

SocialChooserViewController- TWTRAPIClient完成回调正在被调用..(它不会重定向回我的应用程序)

@IBAction func continueLoginWithTwitter() {
    Twitter.sharedInstance().logIn(withMethods: [.webBased]) { session, error in
        guard session != nil else {
            print("error connecting with Twitter: \(error?.localizedDescription)");
            return
        }
        self.chosenMedia = .twtr
        let client = TWTRAPIClient(userID: session!.userID)
        client.loadUser(withID: session!.userID) { (unwrappedTwtrUser, error) in
            guard let twtrUser = unwrappedTwtrUser, error == nil else {
                print("Twitter : TwTRUser is nil, or error has occured: ")
                print("Twitter error: \(error!.localizedDescription)")
                return
            }
            _ = self.user.set(firstAndFamilyName: twtrUser.name)
            self.user.set(imageURL: twtrUser.profileImageMiniURL)
            self.user.set(token: session!.authToken)
            self.performSegue(withIdentifier: "toProfileVC", sender: self)
        }
    }
}

中学:根据我的要求,我还想更改权限页面上显示的应用程序bieng的名称,该怎么做?

权限页面:

enter image description here

ios twitter-fabric
3个回答
9
投票

答案:代表处还有更多更新的方法,twitter调用了不赞成使用的方法(如您在上面看到的),但是我实际上并未在内部处理twitter-因此,没有任何事情在更新的方法下,并且工作得很好且井井有条:

func application(_ application:UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey: Any]) -> Bool {
    print("called")
    let directedByFB = FBSDKApplicationDelegate.sharedInstance().application(application, open: url, options: options)
    let directedByTWTR =  Twitter.sharedInstance().application(application, open: url, options: options)
    let directedByGGL =  GIDSignIn.sharedInstance().handle(url as URL!, sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication] as? String, annotation: options[UIApplicationOpenURLOptionsKey.annotation])
    return directedByGGL || directedByTWTR || directedByFB
}
    

1
投票

为Swift 4.1-Xcode 9.3选择的答案


0
投票
From ios13 we have scenedelegate file so for that with appdelegate openURL method we also need to manage the method in scenedelegate file via the below delegate method for twitter.  

`func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
        if let openURLContext = URLContexts.first{
          let url = openURLContext.url
          let options: [AnyHashable : Any] = [
            UIApplication.OpenURLOptionsKey.annotation : openURLContext.options.annotation as Any,
            UIApplication.OpenURLOptionsKey.sourceApplication : openURLContext.options.sourceApplication as Any,
            UIApplication.OpenURLOptionsKey.openInPlace : openURLContext.options.openInPlace
          ]
          TWTRTwitter.sharedInstance().application(UIApplication.shared, open: url, options: options)
        }
    }`
© www.soinside.com 2019 - 2024. All rights reserved.