ios - Twitter Kit 不能在 Swift 应用程序中重定向
问题描述
TwitterKit 不能在我的应用程序中重定向。
1. Info.Plist 新增行
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>twitterkit-{your consumer key}</string>
</array>
</dict>
</array>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>twitter</string>
<string>twitterauth</string>
</array>
2. 应用委托
import TwitterKit
application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
Twitter.sharedInstance().start(withConsumerKey:consumer_key, consumerSecret:consumer_secret)
}
application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
if Twitter.sharedInstance().application(app, open: url, options: options) {
return true
}
return false
}
3.登录界面
func twitter(){
TWTRTwitter.sharedInstance().logIn(with: self, completion: { (session, error) in
--
})
}
谁能告诉我哪里出错了?
解决方案
这是一个回调问题所以请在 AppDelegate 中评论
func application(_ application: UIApplication, configurationForConnecting connectedSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { } func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { } 并添加 didFinishlaunchWithOption 函数
self.window = UIWindow(frame: UIScreen.main.bounds) 让 vc = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "GoThrough") as!UINavigationController self.window?.rootViewController = vc self.window?.makeKeyAndVisible()
推荐阅读
- npm - 未找到导入的项目“D:\Microsoft.Cpp.Default.props”
- visual-studio - 什么是 VSS 连接
- html - 按钮提交邮件,onclick 调用调用函数,重定向到索引页面并显示消息
- android - Android ViewHolder 中的 getView 有时会返回“null”
- unity3d - 检查器中预制信息中的粗体文本 - Unity
- javascript - 几次尝试后,Axios 没有发出任何请求
- python - 我想制作一个提供标准输出的模式
- android - Android Billing 4.0.0 - 无购买结果 querySkuDetailsAsync()
- javascript - Chrome:在 URL 中发送 API 请求时,以“yyyy-MM-dd”格式发送的日期在 chrome 中更改为“yyyy-dd-MM”
- android - 当我添加一个firebase admin SDK之后我想禁用用户帐户我运行android项目我显示错误