Не авторизуется пользователь в приложении через vk ios sdk
Столкнулся со следующей проблемой: пытаюсь реализовать авторизацию пользователя через VK. Использую для это sdk для IOS. Проблема заключается в том, что в окне авторизации через браузер, когда у пользователя просят подтвердить разрешения для приложения, по нажатию на "allow" не закрывается окно браузера. Т.е., фактически, не вызывается метод vkSdkAccessAuthorizationFinished(). Приложение писал по курсу, представленному на SwiftBook. Причем приложение самого курса работает корректно.
Приложение в VK зарегестрировал. URL-схему настроил. В Info.plist строки из гайда VK вставил. Буду благодарен за любую помощь!
func wakeUpSession() {
let scope = ["offline"]
VKSdk.wakeUpSession(scope) { [delegate] (state, error) in
if state == VKAuthorizationState.authorized {
print("VKAuthorizationState.authorized")
delegate?.authentificationServiceSignIn()
} else if state == VKAuthorizationState.initialized {
print("VKAuthorizationState.initialized")
print("1")
VKSdk.authorize(scope)
// print("2")
} else if state == VKAuthorizationState.error {
print("Auth problem, state \(state) error \(String(describing: error))")
delegate?.authentificationServiceDidSignInFail()
}
}
}
//MARK: - VKSdkDelegate
func vkSdkAccessAuthorizationFinished(with result: VKAuthorizationResult!) {
print(#function)
if result.token != nil {
delegate?.authentificationServiceSignIn()
}
}
func vkSdkUserAuthorizationFailed() {
print(#function)
}
//MARK: - VKSdkUIDelegate
func vkSdkShouldPresent(_ controller: UIViewController!) {
print(#function)
delegate?.authentificationServiceShouldShow(controller)
}
func vkSdkNeedCaptchaEnter(_ captchaError: VKError!) {
print(#function)
}
}
//MARK: - AuthentificationServiceDelegate
extension AppDelegate: AuthentificationServiceDelegate {
func authentificationServiceShouldShow(_ controller: UIViewController) {
guard let window = UIApplication.shared.windows.first(where: { (window) -> Bool in
window.isKeyWindow
})
else { return }
window.rootViewController?.present(controller, animated: true, completion: nil)
print(#function)
}
func authentificationServiceSignIn() {
guard
let newsFeedViewController = UIStoryboard(name: "NewsFeedViewController", bundle: nil).instantiateInitialViewController() as? NewsFeedViewController,
let window = UIApplication.shared.windows.first(where: { (window) -> Bool in
window.isKeyWindow
})
else { return }
let navigationViewController = UINavigationController(rootViewController: newsFeedViewController)
window.rootViewController = navigationViewController
print(#function)
}
func authentificationServiceDidSignInFail() {
print(#function)
}
}