正如标题所描述的那样,它坚持这个状态。 我找不到搜索网络的解决方案。 没有错误...... 使用ios swift
图片(希伯来文)附: 它基本上说:“将你重定向到应用程序,可能需要一些时间......”
代码: AppDelegate -
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
var configureError: NSError?
GGLContext.sharedInstance().configureWithError(&configureError)
assert(configureError == nil, "Error configuring Google services: \(configureError)")
Fabric.with([Twitter.self])
return true
}
//deprecaed - for support
func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
let directedByFB = FBSDKApplicationDelegate.sharedInstance().application(application, open: url, sourceApplication: sourceApplication, annotation: annotation)
let directedByGoogle = GIDSignIn.sharedInstance().handle(url as URL!, sourceApplication: sourceApplication,annotation: annotation)
return directedByFB || directedByGoogle
}
func application(application:UIApplication, openURL url: URL, options: [String: AnyObject]) -> Bool {
if Twitter.sharedInstance().application(application, open: url, options: options) {
return true
}
return GIDSignIn.sharedInstance().handle(url as URL!, sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication.rawValue] as? String, annotation: options[UIApplicationOpenURLOptionsKey.annotation.rawValue])
}
SocialChooserViewController - TWTRAPIClient完成回调被称为..(它不会重定向回我的应用程序)
@IBAction func continueLoginWithTwitter() {
Twitter.sharedInstance().logIn(withMethods: [.webBased]) { session, error in
guard session != nil else {
print("error connecting with Twitter: \(error?.localizedDescription)");
return
}
self.chosenMedia = .twtr
let client = TWTRAPIClient(userID: session!.userID)
client.loadUser(withID: session!.userID) { (unwrappedTwtrUser, error) in
guard let twtrUser = unwrappedTwtrUser, error == nil else {
print("Twitter : TwTRUser is nil, or error has occured: ")
print("Twitter error: \(error!.localizedDescription)")
return
}
_ = self.user.set(firstAndFamilyName: twtrUser.name)
self.user.set(imageURL: twtrUser.profileImageMiniURL)
self.user.set(token: session!.authToken)
self.performSegue(withIdentifier: "toProfileVC", sender: self)
}
}
}
次要的: 作为我所要求的更多我还想要更改权限页面上显示的应用程序名称,该怎么做?
权限页面:
答案 0 :(得分:8)
解答: 代表处有更新的方法, twitter正在调用已弃用的方法(正如您在上面看到的那样),但我并没有实际处理内部的twitter - 所以没有一切都在更新的方法下并且工作得很好并且有条理:
func application(_ application:UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey: Any]) -> Bool {
print("called")
let directedByFB = FBSDKApplicationDelegate.sharedInstance().application(application, open: url, options: options)
let directedByTWTR = Twitter.sharedInstance().application(application, open: url, options: options)
let directedByGGL = GIDSignIn.sharedInstance().handle(url as URL!, sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication] as? String, annotation: options[UIApplicationOpenURLOptionsKey.annotation])
return directedByGGL || directedByTWTR || directedByFB
}
答案 1 :(得分:2)
From ios13 we have scenedelegate file so for that with appdelegate openURL method we also need to manage the method in scenedelegate file via the below delegate method for twitter.
`func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
if let openURLContext = URLContexts.first{
let url = openURLContext.url
let options: [AnyHashable : Any] = [
UIApplication.OpenURLOptionsKey.annotation : openURLContext.options.annotation as Any,
UIApplication.OpenURLOptionsKey.sourceApplication : openURLContext.options.sourceApplication as Any,
UIApplication.OpenURLOptionsKey.openInPlace : openURLContext.options.openInPlace
]
TWTRTwitter.sharedInstance().application(UIApplication.shared, open: url, options: options)
}
}`
答案 2 :(得分:1)
Swift 4.1的选定答案 - Xcode 9.3
Podfile
pod 'FacebookLogin'
pod 'TwitterKit'
pod 'GoogleSignIn'
的AppDelegate
import FacebookCore
import TwitterKit
import GoogleSignIn
...
func application(_ application: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey: Any]) -> Bool {
let directedByFB = SDKApplicationDelegate.shared.application(application, open: url, options: options)
let directedByTWTR = TWTRTwitter.sharedInstance().application(application, open: url, options: options)
let directedByGGL = GIDSignIn.sharedInstance()
.handle(url,
sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication] as? String,
annotation: options[UIApplicationOpenURLOptionsKey.annotation]
)
return directedByFB || directedByTWTR || directedByGGL
}
...
答案 3 :(得分:0)
iOS 14中Xcode 12中的另一个解决方案。
实际上我的登录按钮的类是TWTRLogInButton。 因此,我将其替换为UIButton类型。然后,我很快被重定向到我的应用程序。
例如:-替换
@IBOutlet weak var twitterLoginButton: TWTRLogInButton!
使用
@IBOutlet weak var twitterLoginButton: UIButton!