1
votes

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
Show us what you have tried when app is not installed. - Dharmesh Kheni
@DharmeshKheni updated my answer - Roma
@Roma I have same problem check my answer and question. Here is the link stackoverflow.com/questions/51401016/… - chirag shah
@chiragshah Thank you! +1 for you for this :) - Roma
my app is only opening in safari, how can i open in Twitter app.? - Varinder Singh iPhone Dev

2 Answers

2
votes

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
        }
2
votes

Add callback URL in this format

twitter-twitterid://

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