在我的 iOS 应用程序中,我正在使用 TwitterKit
我遇到的问题是,当未安装 twitter 应用程序时,无法登录用户
我看到了建议添加任何回调 URL 但不再起作用的答案
我尝试了两件事:在他们的文档中搜索,但一无所获。试过这个答案Tweeting using Twitterkit failed when Twitter app is not installed in iOS 11。此解决方案不再起作用
谢谢你的帮助!
在我的 iOS 应用程序中,我正在使用 TwitterKit
我遇到的问题是,当未安装 twitter 应用程序时,无法登录用户
我看到了建议添加任何回调 URL 但不再起作用的答案
我尝试了两件事:在他们的文档中搜索,但一无所获。试过这个答案Tweeting using Twitterkit failed when Twitter app is not installed in iOS 11。此解决方案不再起作用
谢谢你的帮助!
以这种格式添加回调 URL
twitter-twitterid://
(将“twitterid”替换为“你的 twitter 应用程序 ID”)
经过大量的研发,我取得了成功。Twitter 已强制要求回拨网址。我从这个链接找到
您需要在 twitter 仪表板设置的回调 url 中添加twitterkit-123456478:// (twitterkit-consumerKey)。
我用这个方法打开了 safari(确保你添加了 safari 框架)
TWTRTwitter.sharedInstance().logIn(with: self) { (session, error) in
if (session != nil) {
print("signed in as \(session?.userName ?? "")");
} else {
print("error: \(error?.localizedDescription ?? "")");
}
}
应用委托
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
}