iostwitter-fabric

Twitter log-in - Completed sign-in but not being redirected to my app


as the title describes, it stuck on that state. i didnt find a solution searching the net. no error exist... working with ios swift

image (Hebrew) attached: it basically says : "redirecting you back to the app, it might take a few moments.."

'Youre being redirected' page

Code: 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 completion callback is nit being called.. (its not redirecting back to my app)

@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)
        }
    }
}

Secondary: as further to what i have asked i would also want to change the name of the app bieng presented on permission page, how to do it?

Permission page :

enter image description here


Solution

  • ANSWER: there is more updated method at the delegate, twitter was calling the deprecated method (as you can see above) but i didnt actually handled twitter inside - so no everything is under the updated method and works just fine and organized:

    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
    }