iOS twitter login when app is not installed

1.2k Views Asked by At

In my iOS app I'm using TwitterKit

The problem I have faced is that when twitter app is not installed there is no way to log in user

I saw answers that suggesting adding any callback URL but that doesn't work anymore

I have tried 2 things: search in their docs and found nothing. tried this answer Tweeting using Twitterkit fails when Twitter app is not installed in iOS 11. This solution doesn't work anymore

Thanks for any help!

2

There are 2 best solutions below

2
On BEST ANSWER

Add callback URL in this format

twitter-twitterid://

(Replace "twitterid" with "your twitter app id")

1
On

After lot of R&D I got the success. Twitter has made call back url compulsory. I found from this link

You need to add twitterkit-123456478:// (twitterkit-consumerKey) in call back url at twitter dashboard setting.

I used this method for opening safari (make sure you add safari framework)

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

Appdelegate

 func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
           if url.scheme?.caseInsensitiveCompare(("twitterkit-" + TwitterKey.consumerKey)) == .orderedSame{
                TWTRTwitter.sharedInstance().application(app, open: url, options: options)
            }
            return true
        }