1

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!

Roma
  • 1,107
  • 9
  • 19

2 Answers2

2

Add callback URL in this format

twitter-twitterid://

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

NSNoob
  • 5,548
  • 6
  • 41
  • 54
2

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
        }
Chirag Shah
  • 3,034
  • 1
  • 30
  • 61
  • Yes that's correct I'll put @Swalih answer as accepted because he was first. Hope you will understand me. I'll plus this question and your answer at another question similar to this. Thank you! – Roma Jul 26 '18 at 07:12