-
[iOS] 카카오 로그인 에러 (OSStatus error -10814)에러 해결 2023. 1. 22. 21:42
블로그를 참고해서 카카오 로그인 구현을 하다가 에러가 났다.
-canOpenURL: failed for URL: "kakaokompassauth://authorize" - error: "The operation couldn’t be completed. (OSStatus error -10814.)"
10814 에러는 해당 어플이 설치되어 있지 않을 때 발생하는 에러라고 한다.
// // LoginViewController.swift // Weather-Wear // // Created by yeonsu on 2023/01/22. // import UIKit import KakaoSDKUser import KakaoSDKCommon import KakaoSDKAuth class LoginViewController:UIViewController { override func viewDidLoad() { super.viewDidLoad() } @IBAction func kakaoLoginButtonTouchUpInside(_ sender: UIButton) { if (UserApi.isKakaoTalkLoginAvailable()) { //카톡 설치되어있으면 -> 카톡으로 로그인 UserApi.shared.loginWithKakaoTalk {(oauthToken, error) in if let error = error { print(error) } else { print("카카오 톡으로 로그인 성공") _ = oauthToken /// 로그인 관련 메소드 추가 } } }} }
이 코드만 구현했을 때 생기는 에러였다!
카톡이 설치되어 있으면 카카오톡 어플로 로그인하고, 어플이 설치되어 있지 않으면 카카오 계정으로 로그인 할 수 있게 분기를 시켜주지 않아서 에러가 발생한 거다.
else { // 카톡 없으면 -> 계정으로 로그인 UserApi.shared.loginWithKakaoAccount { (oauthToken, error) in if let error = error { print(error) } else { print("카카오 계정으로 로그인 성공") _ = oauthToken // 관련 메소드 추가 } }
해당 코드를 추가해주면 정상적으로 실행되는 것을 확인할 수 있다.