Swift iOS 13 Twitter Login
Возникла проблема с логином через Twitter при переходе на IOS13, появился файл SceneDelegate.swift и из-за него теперь всегда появляется ошибка:
BackgroundTask
Если удалить этот файл, то всё работает, как сделать, чтобы с этим файлом вход через Твиттер работал? Спасибо
AppDelegate.swift
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
internal func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
Twitter.sharedInstance().start(withConsumerKey:"key", consumerSecret:"secret")
return true
}
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
return Twitter.sharedInstance().application(app, open: url, options: options)
}
}
ViewController.swift
let logInButton = TWTRLogInButton(logInCompletion: { session, error in
if (session != nil) {
Twitter.sharedInstance().logIn(with: self) { (session, error) in
if (session != nil) {
print("signed in as \(String(describing: session?.userName))");
self.dismiss(animated: true) {
print("Logged in ")
}
let client = TWTRAPIClient.withCurrentUser()
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
}
let name = twtrUser.name
print(name)
}
} else {
print("error: \(error?.localizedDescription ?? "")");
}
}
} else {
print(error)
}
})
logInButton.center = self.view.center
self.view.addSubview(logInButton)
Twitter.sharedInstance().sessionStore.fetchGuestSession { (guestSession, error) in
if (guestSession != nil) {
} else {
print("error: \(error)");
}
}